(function (factory){ if(typeof define==='function'&&define.amd){ define(['jquery'], factory); }else if(typeof exports==='object'){ module.exports=factory; }else{ factory(jQuery); }}(function ($){ var toFix=['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'], toBind=('onwheel' in document||document.documentMode >=9) ? ['wheel']:['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'], slice=Array.prototype.slice, nullLowestDeltaTimeout, lowestDelta; if($.event.fixHooks){ for(var i=toFix.length; i;){ $.event.fixHooks[ toFix[--i] ]=$.event.mouseHooks; }} var special=$.event.special.mousewheel={ version: '3.1.12', setup: function(){ if(this.addEventListener){ for(var i=toBind.length; i;){ this.addEventListener(toBind[--i], handler, false); }}else{ this.onmousewheel=handler; } $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); }, teardown: function(){ if(this.removeEventListener){ for(var i=toBind.length; i;){ this.removeEventListener(toBind[--i], handler, false); }}else{ this.onmousewheel=null; } $.removeData(this, 'mousewheel-line-height'); $.removeData(this, 'mousewheel-page-height'); }, getLineHeight: function(elem){ var $elem=$(elem), $parent=$elem['offsetParent' in $.fn ? 'offsetParent':'parent'](); if(!$parent.length){ $parent=$('body'); } return parseInt($parent.css('fontSize'), 10)||parseInt($elem.css('fontSize'), 10)||16; }, getPageHeight: function(elem){ return $(elem).height(); }, settings: { adjustOldDeltas: true, normalizeOffset: true }}; $.fn.extend({ mousewheel: function(fn){ return fn ? this.bind('mousewheel', fn):this.trigger('mousewheel'); }, unmousewheel: function(fn){ return this.unbind('mousewheel', fn); }}); function handler(event){ var orgEvent=event||window.event, args=slice.call(arguments, 1), delta=0, deltaX=0, deltaY=0, absDelta=0, offsetX=0, offsetY=0; event=$.event.fix(orgEvent); event.type='mousewheel'; if('detail' in orgEvent){ deltaY=orgEvent.detail * -1; } if('wheelDelta' in orgEvent){ deltaY=orgEvent.wheelDelta; } if('wheelDeltaY' in orgEvent){ deltaY=orgEvent.wheelDeltaY; } if('wheelDeltaX' in orgEvent){ deltaX=orgEvent.wheelDeltaX * -1; } if('axis' in orgEvent&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){ deltaX=deltaY * -1; deltaY=0; } delta=deltaY===0 ? deltaX:deltaY; if('deltaY' in orgEvent){ deltaY=orgEvent.deltaY * -1; delta=deltaY; } if('deltaX' in orgEvent){ deltaX=orgEvent.deltaX; if(deltaY===0){ delta=deltaX * -1; }} if(deltaY===0&&deltaX===0){ return; } if(orgEvent.deltaMode===1){ var lineHeight=$.data(this, 'mousewheel-line-height'); delta *=lineHeight; deltaY *=lineHeight; deltaX *=lineHeight; }else if(orgEvent.deltaMode===2){ var pageHeight=$.data(this, 'mousewheel-page-height'); delta *=pageHeight; deltaY *=pageHeight; deltaX *=pageHeight; } absDelta=Math.max(Math.abs(deltaY), Math.abs(deltaX)); if(!lowestDelta||absDelta < lowestDelta){ lowestDelta=absDelta; if(shouldAdjustOldDeltas(orgEvent, absDelta)){ lowestDelta /=40; }} if(shouldAdjustOldDeltas(orgEvent, absDelta)){ delta /=40; deltaX /=40; deltaY /=40; } delta=Math[ delta >=1 ? 'floor':'ceil' ](delta / lowestDelta); deltaX=Math[ deltaX >=1 ? 'floor':'ceil' ](deltaX / lowestDelta); deltaY=Math[ deltaY >=1 ? 'floor':'ceil' ](deltaY / lowestDelta); if(special.settings.normalizeOffset&&this.getBoundingClientRect){ var boundingRect=this.getBoundingClientRect(); offsetX=event.clientX - boundingRect.left; offsetY=event.clientY - boundingRect.top; } event.deltaX=deltaX; event.deltaY=deltaY; event.deltaFactor=lowestDelta; event.offsetX=offsetX; event.offsetY=offsetY; event.deltaMode=0; args.unshift(event, delta, deltaX, deltaY); if(nullLowestDeltaTimeout){ clearTimeout(nullLowestDeltaTimeout); } nullLowestDeltaTimeout=setTimeout(nullLowestDelta, 200); return ($.event.dispatch||$.event.handle).apply(this, args); } function nullLowestDelta(){ lowestDelta=null; } function shouldAdjustOldDeltas(orgEvent, absDelta){ return special.settings.adjustOldDeltas&&orgEvent.type==='mousewheel'&&absDelta % 120===0; }})); (function($){ "use strict"; $.maxmegamenu=function(menu, options){ var plugin=this; var $menu=$(menu); var $toggle_bar=$menu.siblings(".mega-menu-toggle"); var html_body_class_timeout; var defaults={ event: $menu.attr("data-event"), effect: $menu.attr("data-effect"), effect_speed: parseInt($menu.attr("data-effect-speed")), effect_mobile: $menu.attr("data-effect-mobile"), effect_speed_mobile: parseInt($menu.attr("data-effect-speed-mobile")), panel_width: $menu.attr("data-panel-width"), panel_inner_width: $menu.attr("data-panel-inner-width"), mobile_force_width: $menu.attr("data-mobile-force-width"), mobile_overlay: $menu.attr("data-mobile-overlay"), mobile_state: $menu.attr("data-mobile-state"), second_click: $menu.attr("data-second-click"), vertical_behaviour: $menu.attr("data-vertical-behaviour"), document_click: $menu.attr("data-document-click"), breakpoint: $menu.attr("data-breakpoint"), unbind_events: $menu.attr("data-unbind"), hover_intent_timeout: $menu.attr("data-hover-intent-timeout"), hover_intent_interval: $menu.attr("data-hover-intent-interval") }; plugin.settings={}; var items_with_submenus=$("li.mega-menu-megamenu.mega-menu-item-has-children," + "li.mega-menu-flyout.mega-menu-item-has-children," + "li.mega-menu-tabbed > ul.mega-sub-menu > li.mega-menu-item-has-children," + "li.mega-menu-flyout li.mega-menu-item-has-children", menu); var collapse_children_parents=$("li.mega-menu-megamenu li.mega-menu-item-has-children.mega-collapse-children > a.mega-menu-link", menu); plugin.addAnimatingClass=function(element){ if(plugin.settings.effect==="disabled"){ return; } $(".mega-animating").removeClass("mega-animating"); var timeout=plugin.settings.effect_speed + parseInt(megamenu.timeout, 10); element.addClass("mega-animating"); setTimeout(function(){ element.removeClass("mega-animating"); }, timeout); }; plugin.hideAllPanels=function(){ $(".mega-toggle-on > a.mega-menu-link", $menu).each(function(){ plugin.hidePanel($(this), false); }); }; plugin.expandMobileSubMenus=function(){ $(".mega-menu-item-has-children.mega-expand-on-mobile > a.mega-menu-link", $menu).each(function(){ plugin.showPanel($(this)); }); if(plugin.settings.mobile_state=='expand_all'){ $(".mega-menu-item-has-children > a.mega-menu-link", $menu).each(function(){ plugin.showPanel($(this)); }); } if(plugin.settings.mobile_state=='expand_active'){ $("li.mega-current-menu-ancestor.mega-menu-item-has-children > a.mega-menu-link," + "li.mega-current-menu-item.mega-menu-item-has-children > a.mega-menu-link" + "li.mega-current-menu-parent.mega-menu-item-has-children > a.mega-menu-link" + "li.mega-current_page_ancestor.mega-menu-item-has-children > a.mega-menu-link" + "li.mega-current_page_item.mega-menu-item-has-children > a.mega-menu-link", $menu).each(function(){ plugin.showPanel($(this)); }); }} plugin.hideSiblingPanels=function(anchor, immediate){ anchor.parent().parent().find(".mega-toggle-on").children("a.mega-menu-link").each(function(){ plugin.hidePanel($(this), immediate); }); }; plugin.isDesktopView=function(){ return Math.max(window.outerWidth, $(window).width()) > plugin.settings.breakpoint; }; plugin.isMobileView=function(){ return !plugin.isDesktopView(); }; plugin.showPanel=function(anchor){ anchor.parent().triggerHandler("before_open_panel"); anchor.attr("aria-expanded", "true"); $(".mega-animating").removeClass("mega-animating"); if(plugin.isMobileView()&&anchor.parent().hasClass("mega-hide-sub-menu-on-mobile")){ return; } if(plugin.isDesktopView()&&($menu.hasClass("mega-menu-horizontal")||$menu.hasClass("mega-menu-vertical"))&&!anchor.parent().hasClass("mega-collapse-children")){ plugin.hideSiblingPanels(anchor, true); } if((plugin.isMobileView()&&$menu.hasClass("mega-keyboard-navigation"))||plugin.settings.vertical_behaviour==="accordion"){ plugin.hideSiblingPanels(anchor, false); } plugin.calculateDynamicSubmenuWidths(anchor); if(anchor.parent().hasClass("mega-collapse-children")||plugin.settings.effect==="slide" || (plugin.isMobileView()&&(plugin.settings.effect_mobile==="slide"||plugin.settings.effect_mobile==="slide_left"||plugin.settings.effect_mobile==="slide_right")) ){ var speed=plugin.isMobileView() ? plugin.settings.effect_speed_mobile:plugin.settings.effect_speed; anchor.siblings(".mega-sub-menu").css("display", "none").animate({"height":"show", "paddingTop":"show", "paddingBottom":"show", "minHeight":"show"}, speed, function(){ $(this).css("display", ""); }); } anchor.parent().addClass("mega-toggle-on").triggerHandler("open_panel"); }; plugin.hidePanel=function(anchor, immediate){ anchor.parent().triggerHandler("before_close_panel"); anchor.attr("aria-expanded", "false"); if(anchor.parent().hasClass("mega-collapse-children")||(! immediate&&plugin.settings.effect==="slide") || (plugin.isMobileView()&&(plugin.settings.effect_mobile==="slide"||plugin.settings.effect_mobile==="slide_left"||plugin.settings.effect_mobile==="slide_right")) ){ var speed=plugin.isMobileView() ? plugin.settings.effect_speed_mobile:plugin.settings.effect_speed; anchor.siblings(".mega-sub-menu").animate({"height":"hide", "paddingTop":"hide", "paddingBottom":"hide", "minHeight":"hide"}, speed, function(){ anchor.siblings(".mega-sub-menu").css("display", ""); anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel"); }); return; } if(immediate){ anchor.siblings(".mega-sub-menu").css("display", "none").delay(plugin.settings.effect_speed).queue(function(){ $(this).css("display", "").dequeue(); }); } anchor.siblings(".mega-sub-menu").find(".widget_media_video video").each(function(){ this.player.pause(); }); anchor.parent().removeClass("mega-toggle-on").triggerHandler("close_panel"); plugin.addAnimatingClass(anchor.parent()); }; plugin.calculateDynamicSubmenuWidths=function(anchor){ if(anchor.parent().hasClass("mega-menu-megamenu")&&anchor.parent().parent().hasClass("max-mega-menu")&&plugin.settings.panel_width&&$(plugin.settings.panel_width).length > 0){ if(plugin.isDesktopView()){ var submenu_offset=$menu.offset(); var target_offset=$(plugin.settings.panel_width).offset(); anchor.siblings(".mega-sub-menu").css({ width: $(plugin.settings.panel_width).outerWidth(), left: (target_offset.left - submenu_offset.left) + "px" }); }else{ anchor.siblings(".mega-sub-menu").css({ width: "", left: "" }); }} if(anchor.parent().hasClass("mega-menu-megamenu")&&anchor.parent().parent().hasClass("max-mega-menu")&&plugin.settings.panel_inner_width&&$(plugin.settings.panel_inner_width).length > 0){ var target_width=0; if($(plugin.settings.panel_inner_width).length){ target_width=parseInt($(plugin.settings.panel_inner_width).width(), 10); }else{ target_width=parseInt(plugin.settings.panel_inner_width, 10); } var submenu_width=parseInt(anchor.siblings(".mega-sub-menu").innerWidth(), 10); if(plugin.isDesktopView()&&target_width > 0&&target_width < submenu_width){ anchor.siblings(".mega-sub-menu").css({ "paddingLeft": (submenu_width - target_width) / 2 + "px", "paddingRight": (submenu_width - target_width) / 2 + "px" }); }else{ anchor.siblings(".mega-sub-menu").css({ "paddingLeft": "", "paddingRight": "" }); }} }; plugin.bindClickEvents=function(){ var dragging=false; $(document).on({ "touchmove": function(e){ dragging=true; }, "touchstart": function(e){ dragging=false; }}); $(document).on("click touchend", function(e){ if(!dragging&&plugin.settings.document_click==="collapse"&&! $(e.target).closest(".max-mega-menu li").length&&! $(e.target).closest(".mega-menu-toggle").length){ plugin.hideAllPanels(); plugin.hideMobileMenu(); } dragging=false; }); var clickable_parents=$("> a.mega-menu-link", items_with_submenus).add(collapse_children_parents); clickable_parents.on("touchend.megamenu", function(e){ plugin.unbindHoverEvents(); plugin.unbindHoverIntentEvents(); }); clickable_parents.not("[data-has-click-event]").on("click.megamenu", function(e){ if(plugin.isDesktopView()&&$(this).parent().hasClass("mega-toggle-on")&&$(this).parent().parent().parent().hasClass("mega-menu-tabbed")){ if(plugin.settings.second_click==="go"){ return; }else{ e.preventDefault(); return; }} if(dragging){ return; } if(plugin.isMobileView()&&$(this).parent().hasClass("mega-hide-sub-menu-on-mobile")){ return; } if((plugin.settings.second_click==="go"||$(this).parent().hasClass("mega-click-click-go"))&&$(this).attr("href")!==undefined){ if(!$(this).parent().hasClass("mega-toggle-on")){ e.preventDefault(); plugin.showPanel($(this)); }}else{ e.preventDefault(); if($(this).parent().hasClass("mega-toggle-on")){ plugin.hidePanel($(this), false); }else{ plugin.showPanel($(this)); }} }); collapse_children_parents.each(function(){ $(this).attr('data-has-click-event', 'true'); }); }; plugin.bindHoverEvents=function(){ items_with_submenus.on({ "mouseenter.megamenu":function(){ plugin.unbindClickEvents(); if(! $(this).hasClass("mega-toggle-on")){ plugin.showPanel($(this).children("a.mega-menu-link")); }}, "mouseleave.megamenu":function(){ if($(this).hasClass("mega-toggle-on")&&! $(this).hasClass("mega-disable-collapse")&&! $(this).parent().parent().hasClass("mega-menu-tabbed")){ plugin.hidePanel($(this).children("a.mega-menu-link"), false); }} }); }; plugin.bindHoverIntentEvents=function(){ items_with_submenus.hoverIntent({ over: function (){ plugin.unbindClickEvents(); if(! $(this).hasClass("mega-toggle-on")){ plugin.showPanel($(this).children("a.mega-menu-link")); }}, out: function (){ if($(this).hasClass("mega-toggle-on")&&! $(this).hasClass("mega-disable-collapse")&&! $(this).parent().parent().hasClass("mega-menu-tabbed")){ plugin.hidePanel($(this).children("a.mega-menu-link"), false); }}, timeout: plugin.settings.hover_intent_timeout, interval: plugin.settings.hover_intent_interval }); }; plugin.bindKeyboardEvents=function(){ var tab_key=9; var escape_key=27; var enter_key=13; var left_arrow_key=37; var right_arrow_key=39; var space_key=32; $menu.parent().on("keyup.megamenu", function(e){ var keyCode=e.keyCode||e.which; if(keyCode===tab_key){ $menu.parent().addClass("mega-keyboard-navigation"); }}); $menu.parent().on("keydown.megamenu", function(e){ var keyCode=e.keyCode||e.which; var active_link=$(e.target); if(keyCode===space_key&&active_link.is(".mega-menu-link")&&$menu.parent().hasClass("mega-keyboard-navigation")){ e.preventDefault(); if(active_link.parent().is(items_with_submenus)){ if(active_link.parent().hasClass("mega-toggle-on")&&! active_link.parent().parent().parent().hasClass("mega-menu-tabbed")){ plugin.hidePanel(active_link); }else{ plugin.showPanel(active_link); }} }}); $menu.parent().on("keyup.megamenu", function(e){ var keyCode=e.keyCode||e.which; var active_link=$(e.target); if(keyCode===tab_key&&$menu.parent().hasClass("mega-keyboard-navigation")){ if(active_link.parent().is(items_with_submenus)&&active_link.is("[href]")!==false){ plugin.showPanel(active_link); }else{ if(! active_link.parent().parent().parent().hasClass("mega-menu-tabbed")){ plugin.hideSiblingPanels(active_link); }} } if(keyCode===escape_key&&$menu.parent().hasClass("mega-keyboard-navigation")){ var submenu_open=$("> .mega-toggle-on", $menu).length!==0; $("> .mega-toggle-on > a.mega-menu-link", $menu).focus(); plugin.hideAllPanels(); if(plugin.isMobileView()&&! submenu_open){ plugin.hideMobileMenu(); $(".mega-menu-toggle-block, button.mega-toggle-animated", $toggle_bar).first().focus(); }} if(keyCode===enter_key&&$menu.parent().hasClass("mega-keyboard-navigation")){ if(active_link.hasClass("mega-menu-toggle-block")){ if($toggle_bar.hasClass("mega-menu-open")){ plugin.hideMobileMenu(); }else{ plugin.showMobileMenu(); }} if(active_link.parent().is(items_with_submenus)&&active_link.is("[href]")===false){ if(active_link.parent().hasClass("mega-toggle-on")&&! active_link.parent().parent().parent().hasClass("mega-menu-tabbed")){ plugin.hidePanel(active_link); }else{ plugin.showPanel(active_link); }} } if(keyCode===right_arrow_key&&plugin.isDesktopView()&&$menu.parent().hasClass("mega-keyboard-navigation")&&$menu.hasClass("mega-menu-horizontal")){ var next_top_level_item=$("> .mega-toggle-on", $menu).nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search input[type=text]").first(); if(next_top_level_item.length===0){ next_top_level_item=$(":focus", $menu).parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search input[type=text]").first(); } next_top_level_item.focus(); if(next_top_level_item.parent().is(items_with_submenus)&&next_top_level_item.is("[href]")!==false){ plugin.showPanel(next_top_level_item); }else{ plugin.hideSiblingPanels(next_top_level_item); }} if(keyCode===left_arrow_key&&plugin.isDesktopView()&&$menu.parent().hasClass("mega-keyboard-navigation")&&$menu.hasClass("mega-menu-horizontal")){ var prev_top_level_item=$("> .mega-toggle-on", $menu).prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search input[type=text]").last(); if(prev_top_level_item.length===0){ prev_top_level_item=$(":focus", $menu).parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search input[type=text]").last(); } prev_top_level_item.focus(); if(prev_top_level_item.parent().is(items_with_submenus)&&prev_top_level_item.is("[href]")!==false){ plugin.showPanel(prev_top_level_item); }else{ plugin.hideSiblingPanels(prev_top_level_item); }} }); $menu.parent().on("focusout.megamenu", function(e){ if($menu.parent().hasClass("mega-keyboard-navigation")){ setTimeout(function(){ var menu_has_focus=$menu.parent().find(":focus").length > 0; if(! menu_has_focus){ $menu.parent().removeClass("mega-keyboard-navigation"); plugin.hideAllPanels(); plugin.hideMobileMenu(); }}, 10); }}); }; plugin.unbindAllEvents=function(){ $("ul.mega-sub-menu, li.mega-menu-item, li.mega-menu-row, li.mega-menu-column, a.mega-menu-link, span.mega-indicator", menu).off().unbind(); }; plugin.unbindClickEvents=function(){ $("> a.mega-menu-link", items_with_submenus).not(collapse_children_parents).off("click.megamenu touchend.megamenu"); }; plugin.unbindHoverEvents=function(){ items_with_submenus.unbind("mouseenter.megamenu mouseleave.megamenu"); }; plugin.unbindHoverIntentEvents=function(){ items_with_submenus.unbind("mouseenter mouseleave").removeProp("hoverIntent_t").removeProp("hoverIntent_s"); }; plugin.unbindKeyboardEvents=function(){ $menu.parent().off("keyup.megamenu keydown.megamenu focusout.megamenu"); }; plugin.unbindMegaMenuEvents=function(){ if(plugin.settings.event==="hover_intent"){ plugin.unbindHoverIntentEvents(); } if(plugin.settings.event==="hover"){ plugin.unbindHoverEvents(); } plugin.unbindClickEvents(); plugin.unbindKeyboardEvents(); }; plugin.bindMegaMenuEvents=function(){ plugin.unbindMegaMenuEvents(); if(plugin.isDesktopView()&&plugin.settings.event==="hover_intent"){ plugin.bindHoverIntentEvents(); } if(plugin.isDesktopView()&&plugin.settings.event==="hover"){ plugin.bindHoverEvents(); } plugin.bindClickEvents(); plugin.bindKeyboardEvents(); }; plugin.checkWidth=function(){ if(plugin.isMobileView()&&$menu.data("view")==="desktop"){ plugin.switchToMobile(); } if(plugin.isDesktopView()&&$menu.data("view")==="mobile"){ plugin.switchToDesktop(); } plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu)); }; plugin.reverseRightAlignedItems=function(){ if(! $("body").hasClass("rtl")){ $menu.append($menu.children("li.mega-item-align-right").get().reverse()); }}; plugin.addClearClassesToMobileItems=function(){ $(".mega-menu-row", $menu).each(function(){ $("> .mega-sub-menu > .mega-menu-column:not(.mega-hide-on-mobile)", $(this)).filter(":even").addClass("mega-menu-clear"); }); }; plugin.initDesktop=function(){ $menu.data("view", "desktop"); plugin.bindMegaMenuEvents(); plugin.initIndicators(); }; plugin.switchToDesktop=function(){ $menu.data("view", "desktop"); plugin.bindMegaMenuEvents(); plugin.reverseRightAlignedItems(); plugin.hideAllPanels(); plugin.hideMobileMenu(true); }; plugin.initMobile=function(){ plugin.switchToMobile(); }; plugin.switchToMobile=function(){ $menu.data("view", "mobile"); plugin.bindMegaMenuEvents(); plugin.initIndicators(); plugin.reverseRightAlignedItems(); plugin.addClearClassesToMobileItems(); plugin.hideAllPanels(); plugin.expandMobileSubMenus(); }; plugin.initToggleBar=function(){ $toggle_bar.on("click", function(e){ if($(e.target).is(".mega-menu-toggle, .mega-menu-toggle-custom-block *, .mega-menu-toggle-block, .mega-menu-toggle-animated-block, .mega-menu-toggle-animated-block *, .mega-toggle-blocks-left, .mega-toggle-blocks-center, .mega-toggle-blocks-right, .mega-toggle-label, .mega-toggle-label span")){ e.preventDefault(); if($(this).hasClass("mega-menu-open")){ plugin.hideMobileMenu(); }else{ plugin.showMobileMenu(); }} }); }; plugin.initIndicators=function(){ $("span.mega-indicator", $menu).not("[data-has-click-event]").on("click.megamenu", function(e){ e.preventDefault(); e.stopPropagation(); if($(this).parent().parent().hasClass("mega-toggle-on")){ if(! $(this).parent().parent().parent().parent().hasClass("mega-menu-tabbed")||plugin.isMobileView()){ plugin.hidePanel($(this).parent(), false); }}else{ plugin.showPanel($(this).parent(), false); }}); $("span.mega-indicator", $menu).each(function(){ $(this).attr('data-has-click-event', 'true'); }); } plugin.hideMobileMenu=function(force){ force=force||false; if(! $toggle_bar.is(":visible")&&! force){ return; } html_body_class_timeout=setTimeout(function(){ $("body").removeClass($menu.attr("id") + "-mobile-open"); $("html").removeClass($menu.attr("id") + "-off-canvas-open"); }, plugin.settings.effect_speed_mobile); $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "false"); if(plugin.settings.effect_mobile==="slide"&&! force){ $menu.animate({"height":"hide"}, plugin.settings.effect_speed_mobile, function(){ $menu.css({ width: "", left: "", display: "" }); }); } $menu.css({ width: "", left: "", display: "" }); $toggle_bar.removeClass("mega-menu-open"); $menu.triggerHandler("mmm:hideMobileMenu"); }; plugin.showMobileMenu=function(){ if(! $toggle_bar.is(":visible")){ return; } clearTimeout(html_body_class_timeout); $("body").addClass($menu.attr("id") + "-mobile-open"); if(plugin.settings.effect_mobile==="slide_left"||plugin.settings.effect_mobile==="slide_right"){ $("html").addClass($menu.attr("id") + "-off-canvas-open"); } $(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "true"); plugin.toggleBarForceWidth(); if(plugin.settings.effect_mobile==="slide"){ $menu.animate({"height":"show"}, plugin.settings.effect_speed_mobile); } $toggle_bar.addClass("mega-menu-open"); $menu.triggerHandler("mmm:showMobileMenu"); }; plugin.toggleBarForceWidth=function(){ if($(plugin.settings.mobile_force_width).length&&(plugin.settings.effect_mobile==="slide"||plugin.settings.effect_mobile==="disabled")){ var submenu_offset=$toggle_bar.offset(); var target_offset=$(plugin.settings.mobile_force_width).offset(); $menu.css({ width: $(plugin.settings.mobile_force_width).outerWidth(), left: (target_offset.left - submenu_offset.left) + "px" }); }}; plugin.init=function(){ $menu.triggerHandler("before_mega_menu_init"); plugin.settings=$.extend({}, defaults, options); $menu.removeClass("mega-no-js"); plugin.initToggleBar(); if(plugin.settings.unbind_events==="true"){ plugin.unbindAllEvents(); } $(window).on("load", function(){ plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu)); }); if(plugin.isDesktopView()){ plugin.initDesktop(); }else{ plugin.initMobile(); } $(window).resize(function(){ plugin.checkWidth(); }); $menu.triggerHandler("after_mega_menu_init"); }; plugin.init(); }; $.fn.maxmegamenu=function(options){ return this.each(function(){ if(undefined===$(this).data("maxmegamenu")){ var plugin=new $.maxmegamenu(this, options); $(this).data("maxmegamenu", plugin); }}); }; $(function(){ $(".max-mega-menu").maxmegamenu(); }); }(jQuery)); (function($){ "use strict"; $(function(){ $('body').on('edd_cart_item_added', function(event, data){ $('.mega-menu-edd-cart-total').html(data.total); $('.mega-menu-edd-cart-count').html(data.cart_quantity); }); }); $(".max-mega-menu").on("after_mega_menu_init", function(){ $('li.mega-menu-megamenu').on('open_panel', function(){ var placeholder=$(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder"); var default_src=placeholder.attr('data-default-src'); placeholder.attr('src', default_src); $('.mega-sub-menu [data-image-swap-url]', $(this)).not(['data-preloaded']).each(function(){ $('')[0].src=$(this).attr('data-image-swap-url'); $(this).attr('data-preloaded', 'true'); }); }); $('.mega-sub-menu [data-image-swap-url]').hoverIntent({ over: function (){ var placeholder=$(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder"); var new_src=$(this).attr('data-image-swap-url'); placeholder.attr('src', new_src); }, out: function(){}}); }); })(jQuery); (function($){ "use strict"; $.maxmegamenu_searchbox=function(form, options){ var plugin=this; var form=$(form); var $menu=form.parents('.max-mega-menu'); var $wrap=$menu.parent(); var breakpoint=$menu.attr('data-breakpoint'); var input=$('input[type=text]', form); var icon=$('.search-icon', form); plugin.isDesktopView=function(){ return Math.max(window.outerWidth, $(window).width()) >=breakpoint; }; plugin.monitorView=function(){ if(typeof $menu.data("view")==='undefined'){ if(plugin.isDesktopView()){ $menu.data("view", "desktop"); }else{ $menu.data("view", "mobile"); }} plugin.checkWidth(); $(window).resize(function(){ plugin.checkWidth(); }); }; plugin.checkWidth=function(){ var expanding_search=$("li.mega-menu-item .mega-search.expand-to-left input[type=text], li.mega-menu-item .mega-search.expand-to-right input[type=text]", $menu); if($menu.data("view")==="mobile"){ var placeholder=expanding_search.attr('data-placeholder'); expanding_search.attr('placeholder', placeholder); } if($menu.data("view")==="desktop"){ expanding_search.attr('placeholder', ''); }}; plugin.close_search=function(){ input.val(""); input.attr('placeholder', ''); form.removeClass('mega-search-open'); form.addClass('mega-search-closed'); } plugin.open_search=function(){ input.attr('placeholder', input.attr('data-placeholder')); form.removeClass('mega-search-closed'); form.addClass('mega-search-open'); } plugin.detect_background_click=function(){ var dragging=false; $(document).on({ "touchmove": function(e){ dragging=true; }, "touchstart": function(e){ dragging=false; }}); $(document).on("click touchend", function(e){ if(form.parent().hasClass('mega-static')){ return; } if(! dragging&&! $(e.target).closest(".max-mega-menu li").length&&! $(e.target).closest(".mega-menu-toggle").length){ plugin.close_search(); } dragging=false; }); } plugin.init_replacements_search=function(){ input.val(""); if($menu.data("view")==="mobile"){ $(".search-icon", $menu).on('click', function(e){ $(this).parents(".mega-search").submit(); }); } if($menu.data("view")==="desktop"){ input.on('focus', function(e){ if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-closed')&&$wrap.hasClass('mega-keyboard-navigation')){ plugin.open_search(); }}); input.on('blur', function(e){ if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-open')&&$wrap.hasClass('mega-keyboard-navigation')){ plugin.close_search(); }}); icon.on('click', function(e){ if(form.parent().hasClass('mega-static')){ form.submit(); return; } if(form.hasClass('mega-search-closed')){ plugin.open_search(); input.focus(); }else if(input.val()==''){ plugin.close_search(); }else{ form.submit(); }}); }}; plugin.monitorView(); plugin.init_replacements_search(); plugin.detect_background_click(); }; $.fn.maxmegamenu_searchbox=function(options){ return this.each(function(){ if(undefined===$(this).data('maxmegamenu_searchbox')){ var plugin=new $.maxmegamenu_searchbox(this, options); $(this).data('maxmegamenu_searchbox', plugin); }}); }; $(function(){ $(".max-mega-menu .mega-search").maxmegamenu_searchbox(); }); })(jQuery); (function($){ "use strict"; $.maxmegamenu_toggle_searchbox=function(form, options){ var plugin=this; var form=$(form); var $wrap=form.parents('.mega-menu-wrap'); var input=$("input[type=text]", form); var icon=$(".search-icon", form); plugin.open_search=function(){ input.attr('placeholder', input.attr('data-placeholder')); form.removeClass('mega-search-closed'); form.addClass('mega-search-open'); } plugin.close_search=function(){ input.attr('placeholder', ''); form.removeClass('mega-search-open'); form.addClass('mega-search-closed'); } plugin.init_toggle_search=function(){ input.val(""); input.on('focus', function(e){ if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-closed')&&$wrap.hasClass('mega-keyboard-navigation')){ plugin.open_search(); }}); input.on('blur', function(e){ if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-open')&&$wrap.hasClass('mega-keyboard-navigation')){ plugin.close_search(); }}); icon.on('click', function(e){ if(form.hasClass('static')){ form.submit(); }else if(form.hasClass('mega-search-closed')){ input.focus(); plugin.open_search(); }else if(input.val()==''){ plugin.close_search(); }else{ form.submit(); }}); }; plugin.init_toggle_search(); }; $.fn.maxmegamenu_toggle_searchbox=function(options){ return this.each(function(){ if(undefined===$(this).data('maxmegamenu_toggle_searchbox')){ var plugin=new $.maxmegamenu_toggle_searchbox(this, options); $(this).data('maxmegamenu_toggle_searchbox', plugin); }}); }; $(function(){ $(".mega-menu-toggle .mega-search").maxmegamenu_toggle_searchbox(); }); })(jQuery); (function($){ "use strict"; $.maxmegamenu_sticky=function(menu, options){ var plugin=this; var $menu=$(menu); var $wrap=$menu.parent(); var breakpoint=$menu.attr('data-breakpoint'); var sticky_on_mobile=$menu.attr('data-sticky-mobile'); var sticky_on_desktop=$menu.attr('data-sticky-desktop'); var sticky_expand=$menu.attr('data-sticky-expand'); var sticky_expand_mobile=$menu.attr('data-sticky-expand-mobile'); var sticky_offset=isNaN(parseInt($menu.attr('data-sticky-offset'))) ? 0:parseInt($menu.attr('data-sticky-offset')); var sticky_hide_until_scroll_up=$menu.attr('data-sticky-hide'); var sticky_hide_until_scroll_up_tolerance=isNaN(parseInt($menu.attr('data-sticky-hide-tolerance'))) ? 0:parseInt($menu.attr('data-sticky-hide-tolerance')); var sticky_hide_until_scroll_up_offset=isNaN(parseInt($menu.attr('data-sticky-hide-offset'))) ? 0:parseInt($menu.attr('data-sticky-hide-offset')); var sticky_transition=$menu.attr('data-sticky-transition'); var sticky_menu_offset_top; var sticky_menu_offset_left; var sticky_menu_width; var sticky_menu_width_round_up; var sticky_menu_height; var is_stuck=false; var admin_bar_height=0; var last_scroll_top=0; var saved_scroll_top=0; var is_vertical=$menu.hasClass('mega-menu-vertical')||$menu.hasClass('mega-menu-accordion'); plugin.isDesktopView=function(){ return Math.max(window.outerWidth, $(window).width()) >=breakpoint; }; var sticky_hide_until_scroll_up_enabled=function(){ return $menu.hasClass('mega-menu-horizontal')&&sticky_hide_until_scroll_up=="true"; } var sticky_enabled=function(){ if(plugin.isDesktopView()){ return sticky_on_desktop==='true'; }else{ return sticky_on_mobile==='true'; } return false; }; plugin.calculate_menu_position=function(){ sticky_menu_offset_top=$wrap.offset().top; if($('body').hasClass('admin-bar')&&$("#wpadminbar").is(":visible")&&$("#wpadminbar").css('top')=='0px'&&$("#wpadminbar").css('position')=='fixed'){ admin_bar_height=$('#wpadminbar').height(); sticky_menu_offset_top=sticky_menu_offset_top - admin_bar_height; } if(sticky_offset < 0){ sticky_menu_offset_top=sticky_menu_offset_top + sticky_offset; }else{ sticky_menu_offset_top=sticky_menu_offset_top - sticky_offset; } sticky_menu_offset_left=$menu.parent().offset().left; sticky_menu_width=window.getComputedStyle($wrap[0]).width; sticky_menu_width_round_up=Math.ceil(parseFloat(sticky_menu_width)); sticky_menu_height=$wrap.height(); }; plugin.stick_menu=function(){ is_stuck=true; var total_offset=parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10); if(sticky_offset < 0){ total_offset=parseInt(admin_bar_height, 10); } var placeholder=$("
").addClass("mega-sticky-wrapper").css({ 'height':sticky_menu_height + 'px', 'position' :'static' }); $wrap.addClass('mega-sticky').wrap(placeholder).css({ 'margin-top':total_offset + 'px' }); $("body").addClass($menu.attr("id") + "-mega-sticky"); $menu.css({ 'max-width':sticky_menu_width_round_up + 'px' }); if(sticky_menu_offset_left > 0){ $menu.css({ 'margin-left':sticky_menu_offset_left + 'px' }); } if(is_vertical||sticky_expand==='false'){ $wrap.css({ 'margin-left':'0', 'margin-right':'0', 'width':sticky_menu_width_round_up + 'px', 'left':sticky_menu_offset_left + 'px' }); $menu.css({ 'margin-left':'0' }); } if($(window).width() <=breakpoint){ $wrap.css({ 'width':sticky_menu_width_round_up + 'px' }); if(sticky_expand_mobile==='true'){ $wrap.css({ 'margin-left':'', 'margin-right':'', 'width':'', 'left':'' }); $menu.css({ 'max-width':'', 'margin-left':'', 'width':'', 'left':'' }); }} $wrap.delay(0).queue(function(next){ $(this).addClass('mega-stuck'); next(); }); }; plugin.unstick_menu=function(doing_resize){ doing_resize=doing_resize||false; is_stuck=false; $wrap.removeClass('mega-sticky').removeClass('mega-hide').css({ 'margin':'', 'width':'', 'left': '' }); $("body").removeClass($menu.attr("id") + "-mega-sticky"); if(! doing_resize){ $wrap.delay(0).queue(function(next){ $(this).removeClass('mega-stuck'); next(); }); } $menu.css({ 'margin-left':'', 'max-width':'', 'left':'', 'width':'' }); if(sticky_transition=='true'&&! doing_resize){ var delay=250; }else{ var delay=0; } $wrap.delay(delay).queue(function(next){ $(this).unwrap(); next(); }); }; plugin.mega_sticky_on_scroll=function(){ if(! sticky_enabled()){ return; } var scroll_top=$(window).scrollTop(); if(scroll_top > sticky_menu_offset_top){ if(!is_stuck){ plugin.stick_menu(); }}else{ if(is_stuck){ plugin.unstick_menu(); }} }; var mega_hide_on_scroll_up=function(){ if(sticky_hide_until_scroll_up_enabled()){ if($menu.data("view")==="mobile"&&$('.mega-menu-toggle', $wrap).hasClass('mega-menu-open')){ return; } var scroll_top=$(window).scrollTop(); if(scroll_top < sticky_hide_until_scroll_up_offset){ $wrap.removeClass('mega-hide'); $("body").removeClass($menu.attr("id") + "-mega-hide"); } saved_scroll_top=last_scroll_top; if(scroll_top < last_scroll_top){ if(saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance){ $wrap.removeClass('mega-hide'); $("body").removeClass($menu.attr("id") + "-mega-hide"); }}else{ if(is_stuck&&scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance){ $wrap.addClass('mega-hide'); $("body").addClass($menu.attr("id") + "-mega-hide"); }} last_scroll_top=scroll_top; }} plugin.mega_sticky_on_resize=function(){ if($('input', $wrap).is(':focus')){ return; } if(sticky_enabled()){ if(is_stuck){ plugin.unstick_menu(true); plugin.calculate_menu_position(); plugin.stick_menu(); }else{ plugin.calculate_menu_position(); plugin.mega_sticky_on_scroll(); }}else{ if(is_stuck){ plugin.unstick_menu(); }} }; plugin.init=function(){ plugin.calculate_menu_position(); plugin.mega_sticky_on_scroll(); $('.mega-menu-accordion li.mega-menu-item').on('open_panel', function(){ plugin.calculate_menu_position(); }); var $window=$(window); $window.scroll(function(){ plugin.mega_sticky_on_scroll(); mega_hide_on_scroll_up(); }); var windowWidth=$window.width(); var resizeTimer; $window.resize(function(){ clearTimeout(resizeTimer); resizeTimer=setTimeout(function(){ windowWidth=$window.width(); plugin.mega_sticky_on_resize(); }, 100); }); }; plugin.init(); }; $.fn.maxmegamenu_sticky=function(options){ return this.each(function(){ if(undefined===$(this).data('maxmegamenu_sticky')){ var plugin=new $.maxmegamenu_sticky(this, options); $(this).data('maxmegamenu_sticky', plugin); }}); }; $(window).on('load', function (e){ $(".mega-menu[data-sticky-enabled]").maxmegamenu_sticky(); }); })(jQuery); (function($){ $(function(){ var calculate_tabbed_sub_menu_widths=function(menu_item){ var menu=menu_item.parents('.max-mega-menu'); if($(menu.attr('data-panel-inner-width')).length > 0){ if(menu.data("view")==="desktop"){ $('> ul.mega-sub-menu', menu_item).each(function(){ var tab_content=$(this); var parent_submenu_content_width=parseInt(tab_content.width()); var parent_submenu_left_padding=parseInt(tab_content.css('paddingLeft')); var tabs_width=$(this).find('a.mega-menu-link').first().outerWidth(); $('> li.mega-menu-item > ul.mega-sub-menu', $(this)).each(function(){ $(this).css('width', parent_submenu_content_width - tabs_width + 'px'); $(this).css('left', parent_submenu_left_padding + tabs_width + 'px'); }); }); }else{ $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function(){ $(this).css('width', ''); $(this).css('left', ''); }); }} } var calculate_tabbed_sub_menu_heights=function(menu_item){ var menu=menu_item.parents('.max-mega-menu'); var max_height=0; if(menu.data("view")==="desktop"){ $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); $('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function(){ var tab_content=$(this); var this_height=parseInt(tab_content.css('height')); if(this_height > max_height){ max_height=this_height; }}); var border_top_width=parseInt($('> ul.mega-sub-menu', menu_item).css('borderTopWidth'),10); var border_bottom_width=parseInt($('> ul.mega-sub-menu', menu_item).css('borderBottomWidth'),10); $('> ul.mega-sub-menu', menu_item).css('minHeight', max_height + border_bottom_width + border_top_width); }else{ $('> ul.mega-sub-menu', menu_item).css('minHeight', ''); }} var $window=$(window); var windowWidth=$window.width(); $window.resize(function(){ if($window.width()!=windowWidth){ calculate_tabbed_sub_menu_widths($('li.mega-menu-tabbed')); calculate_tabbed_sub_menu_heights($('li.mega-menu-tabbed')); }}); $('li.mega-menu-tabbed, li.mega-menu-tabbed li.mega-collapse-children').on('open_panel', function(){ var menu=$(this).parents('.max-mega-menu'); var menu_item=$(this).closest(".mega-menu-tabbed"); calculate_tabbed_sub_menu_widths(menu_item); $("> ul.mega-sub-menu", $(this)).promise().done(function(){ calculate_tabbed_sub_menu_heights(menu_item); }); if(menu.data('view')=='desktop'){ if($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length==0){ if($('> ul.mega-sub-menu > li.mega-current-menu-item:visible', menu_item).length){ $('> ul.mega-sub-menu > li.mega-current-menu-item:visible', menu_item).first().addClass('mega-toggle-on'); }else if($('> ul.mega-sub-menu > li.mega-current-menu-ancestor:visible', menu_item).length){ $('> ul.mega-sub-menu > li.mega-current-menu-ancestor:visible', menu_item).first().addClass('mega-toggle-on'); } if($('> ul.mega-sub-menu > li.mega-toggle-on', menu_item).length==0){ $('> ul.mega-sub-menu > li.mega-menu-item-has-children:visible', menu_item).first().addClass('mega-toggle-on'); }} $('li.mega-menu-tabbed', menu).on('close_panel', function(){ $('li.mega-menu-tabbed .mega-toggle-on', menu).removeClass('mega-toggle-on'); }); } $('li.mega-menu-tabbed li.mega-collapse-children').on('close_panel', function(){ var menu_item=$(this).closest('.mega-menu-tabbed'); $("> ul.mega-sub-menu", $(this)).promise().done(function(){ calculate_tabbed_sub_menu_heights(menu_item); }); }); }); }); })(jQuery); jQuery(document).ready(function($){ const sdccCSSFile='https://suitedash.com/wp-content/uploads/custom-css-js/34206.css'; var sdccCurrentClass=''; var sdccCurrentIndex=null; var sdccIsShowList={}; var sdccClassList=[]; var sdccBeaconIframe=null; var sdccBeaconIframeBody=null; function sdccSetClass($class){ for (i=0; i < sdccClassList.length; i++){ if(sdccBeaconIframe){ sdccBeaconIframeBody.removeClass(sdccClassList[i]); } jQuery('body').removeClass(sdccClassList[i]); } if($class){ if(sdccBeaconIframe){ sdccBeaconIframeBody.addClass($class); } jQuery('body').addClass($class); } sdccCurrentClass=$class; } function sdccInitClasses(){ var sdccCurrentElement=0; jQuery('.js-sd-color-change').each(function(){ sdccClassList.push(this.dataset.class); if(this.getBoundingClientRect().top < 0&&(this.getBoundingClientRect().top > sdccCurrentElement||sdccCurrentElement===0)){ sdccCurrentElement=this.getBoundingClientRect().top; sdccCurrentClass=this.dataset.class; sdccCurrentIndex=this.dataset.index * 1; }}); sdccSetClass(sdccCurrentClass); } if(typeof Beacon==="function"){ Beacon('once', 'ready', ()=> { setTimeout(()=> { let sdccBeacon=jQuery('#beacon-container iframe'); if(sdccBeacon){ sdccBeaconIframe=sdccBeacon.contents(); sdccBeaconIframe.find("head").append(''); sdccBeaconIframeBody=sdccBeaconIframe.find("body"); if(sdccCurrentClass){ sdccSetClass(sdccCurrentClass); }} }, 1000); }); } var sdccObserver=new IntersectionObserver(function(entries){ entries.forEach(entry=> { var newClass=entry.target.dataset.class; if(entry.isIntersecting===true){ if(entry.target.dataset.class){ sdccIsShowList[newClass]=true; if(newClass!==sdccCurrentClass){ sdccCurrentIndex=entry.target.dataset.index * 1; sdccSetClass(newClass); }} }else if(sdccIsShowList[newClass]){ sdccIsShowList[newClass]=false; let el=entry.target.getBoundingClientRect(); if(el.top > 0){ if(sdccCurrentIndex > 0){ sdccCurrentIndex--; sdccSetClass(sdccClassList[sdccCurrentIndex]); }else{ sdccCurrentIndex=null; sdccSetClass(''); }} }}); }, { threshold: [0] }); sdccInitClasses(); const sdccElements=document.querySelectorAll('.js-sd-color-change'); sdccElements.forEach(i=> { sdccObserver.observe(i); }); }); var frmFrontForm; function frmFrontFormJS(){var action="";var jsErrors=[];function maybeShowLabel(){var $field=jQuery(this),$label=$field.closest(".frm_inside_container").find(".frm_primary_label"),val=$field.val();if(val!==null&&val.length>0)$label.addClass("frm_visible");else $label.removeClass("frm_visible")}function getFieldId(field,fullID){var nameParts,fieldId,isRepeating=false,fieldName="";if(field instanceof jQuery)fieldName=field.attr("name");else fieldName=field.name;if(typeof fieldName==="undefined")fieldName= "";if(fieldName===""){if(field instanceof jQuery)fieldName=field.data("name");else fieldName=field.getAttribute("data-name");if(typeof fieldName==="undefined")fieldName="";if(fieldName!==""&&fieldName)return fieldName;return 0}nameParts=fieldName.replace("item_meta[","").replace("[]","").split("]");if(nameParts.length<1)return 0;nameParts=nameParts.filter(function(n){return n!==""});fieldId=nameParts[0];if(nameParts.length===1)return fieldId;if(nameParts[1]==="[form"||nameParts[1]==="[row_ids")return 0; if(jQuery('input[name="item_meta['+fieldId+'][form]"]').length){fieldId=nameParts[2].replace("[","");isRepeating=true}if("other"===fieldId)if(isRepeating)fieldId=nameParts[3].replace("[","");else fieldId=nameParts[1].replace("[","");if(fullID===true)if(fieldId===nameParts[0])fieldId=fieldId+"-"+nameParts[1].replace("[","");else fieldId=fieldId+"-"+nameParts[0]+"-"+nameParts[1].replace("[","");return fieldId}function disableSubmitButton($form){$form.find('input[type="submit"], input[type="button"], button[type="submit"]').attr("disabled", "disabled")}function enableSubmitButton($form){$form.find('input[type="submit"], input[type="button"], button[type="submit"]').removeAttr("disabled")}function disableSaveDraft($form){$form.find("a.frm_save_draft").css("pointer-events","none")}function enableSaveDraft($form){$form.find("a.frm_save_draft").css("pointer-events","")}function validateForm(object){var r,rl,n,nl,fields,field,value,requiredFields,errors=[];requiredFields=jQuery(object).find(".frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea").filter(":not(.frm_optional)"); if(requiredFields.length)for(r=0,rl=requiredFields.length;r0)for(key in errors)addFieldError($fieldCont,key,errors)}function checkRequiredField(field,errors){var checkGroup,fieldClasses,tempVal,i,placeholder,val="",fieldID="",fileID=field.getAttribute("data-frmfile");if(field.type==="hidden"&&fileID===null)return errors;if(field.type==="checkbox"||field.type==="radio"){checkGroup= jQuery('input[name="'+field.name+'"]').closest(".frm_required_field").find("input:checked");jQuery(checkGroup).each(function(){val=this.value})}else if(field.type==="file"||fileID){if(typeof fileID==="undefined"){fileID=getFieldId(field,true);fileID=fileID.replace("file","")}if(typeof errors[fileID]==="undefined")val=getFileVals(fileID);fieldID=fileID}else{fieldClasses=field.className;if(fieldClasses.indexOf("frm_pos_none")!==-1)return errors;val=jQuery(field).val();if(val===null)val="";else if(typeof val!=="string"){tempVal=val;val="";for(i=0;i()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;if(""!==field.value&&pattern.test(field.value)===false)errors[fieldID]=getFieldValidationMessage(field,"data-invmsg");confirmField(field,errors);return errors}function checkPasswordField(field,errors){confirmField(field, errors);return errors}function confirmField(field,errors){var value,confirmValue,firstField,fieldID=getFieldId(field,true),strippedId=field.id.replace("conf_",""),strippedFieldID=fieldID.replace("conf_",""),confirmField=document.getElementById(strippedId.replace("field_","field_conf_"));if(confirmField===null||typeof errors["conf_"+strippedFieldID]!=="undefined")return;if(fieldID!==strippedFieldID){firstField=document.getElementById(strippedId);value=firstField.value;confirmValue=confirmField.value; if(""!==value&&""!==confirmValue&&value!==confirmValue)errors["conf_"+strippedFieldID]=getFieldValidationMessage(confirmField,"data-confmsg")}else validateField("conf_"+strippedFieldID,confirmField)}function checkNumberField(field,errors){var fieldID,number=field.value;if(number!==""&&isNaN(number/1)!==false){fieldID=getFieldId(field,true);if(!(fieldID in errors))errors[fieldID]=getFieldValidationMessage(field,"data-invmsg")}return errors}function checkPatternField(field,errors){var fieldID,text= field.value,format=getFieldValidationMessage(field,"pattern");if(format!==""&&text!==""){fieldID=getFieldId(field,true);if(!(fieldID in errors)){format=new RegExp("^"+format+"$","i");if(format.test(text)===false)errors[fieldID]=getFieldValidationMessage(field,"data-invmsg")}}return errors}function hasInvisibleRecaptcha(object){var recaptcha,recaptchaID,alreadyChecked;if(isGoingToPrevPage(object))return false;recaptcha=jQuery(object).find('.frm-g-recaptcha[data-size="invisible"], .g-recaptcha[data-size="invisible"]'); if(recaptcha.length){recaptchaID=recaptcha.data("rid");alreadyChecked=grecaptcha.getResponse(recaptchaID);if(alreadyChecked.length===0)return recaptcha;else return false}else return false}function executeInvisibleRecaptcha(invisibleRecaptcha){var recaptchaID=invisibleRecaptcha.data("rid");grecaptcha.reset(recaptchaID);grecaptcha.execute(recaptchaID)}function validateRecaptcha(form,errors){var recaptchaID,response,fieldContainer,fieldID,$recaptcha=jQuery(form).find(".frm-g-recaptcha");if($recaptcha.length){recaptchaID= $recaptcha.data("rid");try{response=grecaptcha.getResponse(recaptchaID)}catch(e){if(jQuery(form).find('input[name="recaptcha_checked"]').length)return errors;else response=""}if(response.length===0){fieldContainer=$recaptcha.closest(".frm_form_field");fieldID=fieldContainer.attr("id").replace("frm_field_","").replace("_container","");errors[fieldID]=""}}return errors}function getFieldValidationMessage(field,messageType){var msg=field.getAttribute(messageType);if(msg===null)msg="";return msg}function shouldJSValidate(object){var validate= jQuery(object).hasClass("frm_js_validate");if(validate&&typeof frmProForm!=="undefined"&&(frmProForm.savingDraft(object)||frmProForm.goingToPreviousPage(object)))validate=false;return validate}function getFormErrors(object,action){var fieldset;if(typeof action==="undefined")jQuery(object).find('input[name="frm_action"]').val();fieldset=jQuery(object).find(".frm_form_field");fieldset.addClass("frm_doing_ajax");jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:jQuery(object).serialize()+"&action=frm_entries_"+ action+"&nonce="+frm_js.nonce,success:function(response){var formID,replaceContent,pageOrder,formReturned,contSubmit,delay,$fieldCont,key,inCollapsedSection,frmTrigger,defaultResponse={"content":"","errors":{},"pass":false};if(response===null)response=defaultResponse;response=response.replace(/^\s+|\s+$/g,"");if(response.indexOf("{")===0)response=jQuery.parseJSON(response);else response=defaultResponse;if(typeof response.redirect!=="undefined"){jQuery(document).trigger("frmBeforeFormRedirect",[object, response]);window.location=response.redirect}else if(response.content!==""){removeSubmitLoading(jQuery(object));if(frm_js.offset!=-1)frmFrontForm.scrollMsg(jQuery(object),false);formID=jQuery(object).find('input[name="form_id"]').val();response.content=response.content.replace(/ frm_pro_form /g," frm_pro_form frm_no_hide ");replaceContent=jQuery(object).closest(".frm_forms");removeAddedScripts(replaceContent,formID);delay=maybeSlideOut(replaceContent,response.content);setTimeout(function(){var container, input,previousInput;replaceContent.replaceWith(response.content);addUrlParam(response);if(typeof frmThemeOverride_frmAfterSubmit==="function"){pageOrder=jQuery('input[name="frm_page_order_'+formID+'"]').val();formReturned=jQuery(response.content).find('input[name="form_id"]').val();frmThemeOverride_frmAfterSubmit(formReturned,pageOrder,response.content,object)}if(typeof response.recaptcha!=="undefined"){container=jQuery("#frm_form_"+formID+"_container").find(".frm_fields_container");input='';previousInput=container.find('input[name="recaptcha_checked"]');if(previousInput.length)previousInput.replaceWith(input);else container.append(input)}afterFormSubmitted(object,response)},delay)}else if(Object.keys(response.errors).length){removeSubmitLoading(jQuery(object),"enable");contSubmit=true;removeAllErrors();$fieldCont=null;for(key in response.errors){$fieldCont=jQuery(object).find("#frm_field_"+key+"_container");if($fieldCont.length){if(!$fieldCont.is(":visible")){inCollapsedSection= $fieldCont.closest(".frm_toggle_container");if(inCollapsedSection.length){frmTrigger=inCollapsedSection.prev();if(!frmTrigger.hasClass("frm_trigger"))frmTrigger=frmTrigger.prev(".frm_trigger");frmTrigger.click()}}if($fieldCont.is(":visible")){addFieldError($fieldCont,key,response.errors);contSubmit=false}}}jQuery(object).find(".frm-g-recaptcha, .g-recaptcha").each(function(){var $recaptcha=jQuery(this),recaptchaID=$recaptcha.data("rid");if(typeof grecaptcha!=="undefined"&&grecaptcha)if(recaptchaID)grecaptcha.reset(recaptchaID); else grecaptcha.reset()});jQuery(document).trigger("frmFormErrors",[object,response]);fieldset.removeClass("frm_doing_ajax");scrollToFirstField(object);if(contSubmit)object.submit();else jQuery(object).prepend(response.error_message)}else{showFileLoading(object);object.submit()}},error:function(){jQuery(object).find('input[type="submit"], input[type="button"]').removeAttr("disabled");object.submit()}})}function afterFormSubmitted(object,response){var formCompleted=jQuery(response.content).find(".frm_message"); if(formCompleted.length)jQuery(document).trigger("frmFormComplete",[object,response]);else jQuery(document).trigger("frmPageChanged",[object,response])}function removeAddedScripts(formContainer,formID){var endReplace=jQuery(".frm_end_ajax_"+formID);if(endReplace.length){formContainer.nextUntil(".frm_end_ajax_"+formID).remove();endReplace.remove()}}function maybeSlideOut(oldContent,newContent){var c,newClass="frm_slideout";if(newContent.indexOf(" frm_slide")!==-1){c=oldContent.children();if(newContent.indexOf(" frm_going_back")!==-1)newClass+=" frm_going_back";c.removeClass("frm_going_back");c.addClass(newClass);return 300}return 0}function addUrlParam(response){var url;if(history.pushState&&typeof response.page!=="undefined"){url=addQueryVar("frm_page",response.page);window.history.pushState({"html":response.html},"","?"+url)}}function addQueryVar(key,value){var kvp,i,x;key=encodeURI(key);value=encodeURI(value);kvp=document.location.search.substr(1).split("&");i=kvp.length;while(i--){x=kvp[i].split("=");if(x[0]==key){x[1]= value;kvp[i]=x.join("=");break}}if(i<0)kvp[kvp.length]=[key,value].join("=");return kvp.join("&")}function addFieldError($fieldCont,key,jsErrors){var input,id,describedBy;if($fieldCont.length&&$fieldCont.is(":visible")){$fieldCont.addClass("frm_blank_field");input=$fieldCont.find("input, select, textarea");id="frm_error_field_"+key;describedBy=input.attr("aria-describedby");if(typeof frmThemeOverride_frmPlaceError==="function")frmThemeOverride_frmPlaceError(key,jsErrors);else{$fieldCont.append('
'+jsErrors[key]+"
");if(typeof describedBy==="undefined")describedBy=id;else if(describedBy.indexOf(id)===-1)describedBy=describedBy+" "+id;input.attr("aria-describedby",describedBy)}input.attr("aria-invalid",true);jQuery(document).trigger("frmAddFieldError",[$fieldCont,key,jsErrors])}}function removeFieldError($fieldCont){var errorMessage=$fieldCont.find(".frm_error"),errorId=errorMessage.attr("id"),input=$fieldCont.find("input, select, textarea"),describedBy=input.attr("aria-describedby"); $fieldCont.removeClass("frm_blank_field has-error");errorMessage.remove();input.attr("aria-invalid",false);if(typeof describedBy!=="undefined"){describedBy=describedBy.replace(errorId,"");input.attr("aria-describedby",describedBy)}}function removeAllErrors(){jQuery(".form-field").removeClass("frm_blank_field has-error");jQuery(".form-field .frm_error").replaceWith("");jQuery(".frm_error_style").remove()}function scrollToFirstField(object){var field=jQuery(object).find(".frm_blank_field:first");if(field.length)frmFrontForm.scrollMsg(field, object,true)}function showSubmitLoading($object){showLoadingIndicator($object);disableSubmitButton($object);disableSaveDraft($object)}function showLoadingIndicator($object){if(!$object.hasClass("frm_loading_form")&&!$object.hasClass("frm_loading_prev")){addLoadingClass($object);$object.trigger("frmStartFormLoading")}}function addLoadingClass($object){var loadingClass=isGoingToPrevPage($object)?"frm_loading_prev":"frm_loading_form";$object.addClass(loadingClass)}function isGoingToPrevPage($object){return typeof frmProForm!=="undefined"&&frmProForm.goingToPreviousPage($object)}function removeSubmitLoading($object,enable,processesRunning){var loadingForm;if(processesRunning>0)return;loadingForm=jQuery(".frm_loading_form");loadingForm.removeClass("frm_loading_form");loadingForm.removeClass("frm_loading_prev");loadingForm.trigger("frmEndFormLoading");if(enable==="enable"){enableSubmitButton(loadingForm);enableSaveDraft(loadingForm)}}function showFileLoading(object){var fileval,loading=document.getElementById("frm_loading"); if(loading!==null){fileval=jQuery(object).find("input[type=file]").val();if(typeof fileval!=="undefined"&&fileval!=="")setTimeout(function(){jQuery(loading).fadeIn("slow")},2E3)}}function clearDefault(){toggleDefault(jQuery(this),"clear")}function replaceDefault(){toggleDefault(jQuery(this),"replace")}function toggleDefault($thisField,e){var thisVal,v=$thisField.data("frmval").replace(/(\n|\r\n)/g,"\r");if(v===""||typeof v==="undefined")return false;thisVal=$thisField.val().replace(/(\n|\r\n)/g,"\r"); if("replace"===e){if(thisVal==="")$thisField.addClass("frm_default").val(v)}else if(thisVal==v)$thisField.removeClass("frm_default").val("")}function resendEmail(){var $link=jQuery(this),entryId=this.getAttribute("data-eid"),formId=this.getAttribute("data-fid"),label=$link.find(".frm_link_label");if(label.length<1)label=$link;label.append('');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:entryId,form_id:formId,nonce:frm_js.nonce}, success:function(msg){var admin=document.getElementById("wpbody");if(admin===null)label.html(msg);else{label.html("");$link.after(msg)}}});return false}function confirmClick(){var message=jQuery(this).data("frmconfirm");return confirm(message)}function toggleDiv(){var div=jQuery(this).data("frmtoggle");if(jQuery(div).is(":visible"))jQuery(div).slideUp("fast");else jQuery(div).slideDown("fast");return false}function addIndexOfFallbackForIE8(){var len,from;if(!Array.prototype.indexOf)Array.prototype.indexOf= function(elt){len=this.length>>>0;from=Number(arguments[1])||0;from=from<0?Math.ceil(from):Math.floor(from);if(from<0)from+=len;for(;from>>0;if(typeof fun!=="function")throw new TypeError;res=[];thisp=arguments[1];for(i=0;i-1;if(!isPro)return}if(jQuery("body").hasClass("wp-admin")&&jQuery(object).closest(".frmapi-form").length<1)return;e.preventDefault();if(typeof frmProForm!=="undefined"&&typeof frmProForm.submitAllowed==="function")if(!frmProForm.submitAllowed(object))return;if(invisibleRecaptcha.length){showLoadingIndicator(jQuery(object));executeInvisibleRecaptcha(invisibleRecaptcha)}else{errors=frmFrontForm.validateFormSubmit(object); if(Object.keys(errors).length===0){showSubmitLoading(jQuery(object));frmFrontForm.submitFormNow(object,classList)}}},submitFormNow:function(object){var hasFileFields,classList=object.className.trim().split(/\s+/gi);if(classList.indexOf("frm_ajax_submit")>-1){hasFileFields=jQuery(object).find('input[type="file"]').filter(function(){return!!this.value}).length;if(hasFileFields<1){action=jQuery(object).find('input[name="frm_action"]').val();frmFrontForm.checkFormErrors(object,action)}else object.submit()}else object.submit()}, validateFormSubmit:function(object){if(typeof tinyMCE!=="undefined"&&jQuery(object).find(".wp-editor-wrap").length)tinyMCE.triggerSave();jsErrors=[];if(shouldJSValidate(object)){frmFrontForm.getAjaxFormErrors(object);if(Object.keys(jsErrors).length)frmFrontForm.addAjaxFormErrors(object)}return jsErrors},getAjaxFormErrors:function(object){var customErrors,key;jsErrors=validateForm(object);if(typeof frmThemeOverride_jsErrors==="function"){action=jQuery(object).find('input[name="frm_action"]').val(); customErrors=frmThemeOverride_jsErrors(action,object);if(Object.keys(customErrors).length)for(key in customErrors)jsErrors[key]=customErrors[key]}return jsErrors},addAjaxFormErrors:function(object){var key,$fieldCont;removeAllErrors();for(key in jsErrors){$fieldCont=jQuery(object).find("#frm_field_"+key+"_container");if($fieldCont.length)addFieldError($fieldCont,key,jsErrors);else delete jsErrors[key]}scrollToFirstField(object)},checkFormErrors:function(object,action){getFormErrors(object,action)}, checkRequiredField:function(field,errors){return checkRequiredField(field,errors)},showSubmitLoading:function($object){showSubmitLoading($object)},removeSubmitLoading:function($object,enable,processesRunning){removeSubmitLoading($object,enable,processesRunning)},scrollToID:function(id){var object=jQuery(document.getElementById(id));frmFrontForm.scrollMsg(object,false)},scrollMsg:function(id,object,animate){var newPos,m,b,screenTop,screenBottom,scrollObj="";if(typeof object==="undefined"){scrollObj= jQuery(document.getElementById("frm_form_"+id+"_container"));if(scrollObj.length<1)return}else if(typeof id==="string")scrollObj=jQuery(object).find("#frm_field_"+id+"_container");else scrollObj=id;scrollObj.focus();newPos=scrollObj.offset().top;if(!newPos||frm_js.offset==="-1")return;newPos=newPos-frm_js.offset;m=jQuery("html").css("margin-top");b=jQuery("body").css("margin-top");if(m||b)newPos=newPos-parseInt(m)-parseInt(b);if(newPos&&window.innerHeight){screenTop=document.documentElement.scrollTop|| document.body.scrollTop;screenBottom=screenTop+window.innerHeight;if(newPos>screenBottom||newPos/g,">").replace(/"/g,""").replace(/'/g,"'")},invisible:function(classes){jQuery(classes).css("visibility","hidden")},visible:function(classes){jQuery(classes).css("visibility","visible")}}}frmFrontForm=frmFrontFormJS();jQuery(document).ready(function(){frmFrontForm.init()});function frmRecaptcha(){var c,cl,captchas=jQuery(".frm-g-recaptcha");for(c=0,cl=captchas.length;c');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_update_field_ajax",entry_id:entryId,field_id:fieldId,value:value,nonce:frm_js.nonce},success:function(){if(message.replace(/^\s+|\s+$/g,"")==="")jQuery(document.getElementById("frm_update_field_"+entryId+"_"+fieldId+"_"+num)).fadeOut("slow");else jQuery(document.getElementById("frm_update_field_"+ entryId+"_"+fieldId+"_"+num)).replaceWith(message)}})} function frmDeleteEntry(entryId,prefix){console.warn("DEPRECATED: function frmDeleteEntry in v2.0.13 use frmFrontForm.deleteEntry");jQuery(document.getElementById("frm_delete_"+entryId)).replaceWith('');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:entryId,nonce:frm_js.nonce},success:function(html){if(html.replace(/^\s+|\s+$/g,"")==="success")jQuery(document.getElementById(prefix+entryId)).fadeOut("slow"); else jQuery(document.getElementById("frm_delete_"+entryId)).replaceWith(html)}})}function frmOnSubmit(e){console.warn("DEPRECATED: function frmOnSubmit in v2.0 use frmFrontForm.submitForm");frmFrontForm.submitForm(e,this)} function frm_resend_email(entryId,formId){var $link=jQuery(document.getElementById("frm_resend_email"));console.warn("DEPRECATED: function frm_resend_email in v2.0");$link.append('');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_send_email",entry_id:entryId,form_id:formId,nonce:frm_js.nonce},success:function(msg){$link.replaceWith(msg)}})}; function frmProFormJS(){var currentlyAddingRow=false;var action="";var processesRunning=0;var lookupQueues={};var hiddenSubmitButtons=[];function setNextPage(e){var $thisObj=jQuery(this);var thisType=$thisObj.attr("type");if(thisType!=="submit")e.preventDefault();var f=$thisObj.parents("form:first"),v="",d="",thisName=this.name;if(thisName==="frm_prev_page"||this.className.indexOf("frm_prev_page")!==-1)v=jQuery(f).find(".frm_next_page").attr("id").replace("frm_next_p_","");else if(thisName==="frm_save_draft"|| this.className.indexOf("frm_save_draft")!==-1)d=1;else if(this.className.indexOf("frm_page_skip")!==-1){var goingTo=$thisObj.data("page");var formId=jQuery(f).find('input[name="form_id"]').val();var orderField=jQuery(f).find('input[name="frm_page_order_'+formId+'"]');jQuery(f).append('');if(goingTo==="")orderField.remove();else orderField.val(goingTo)}else if(this.className.indexOf("frm_page_back")!==-1)v=$thisObj.data("page"); var removeIds=[];jQuery(".frm_form_field .wp-editor-area").each(function(){removeIds.push(this.id)});jQuery(document).one("frmPageChanged",function(){for(var removeIndex=0;removeIndex0)max=max-uploadedCount}var form=field.closest("form");field.dropzone({url:frm_js.ajax_url,addRemoveLinks:false,paramName:field.attr("id").replace("_dropzone", ""),maxFilesize:uploadFields[i].maxFilesize,maxFiles:max,uploadMultiple:uploadFields[i].uploadMultiple,hiddenInputContainer:field.parent()[0],dictDefaultMessage:uploadFields[i].defaultMessage,dictFallbackMessage:uploadFields[i].fallbackMessage,dictFallbackText:uploadFields[i].fallbackText,dictFileTooBig:uploadFields[i].fileTooBig,dictInvalidFileType:uploadFields[i].invalidFileType,dictResponseError:uploadFields[i].responseError,dictCancelUpload:uploadFields[i].cancel,dictCancelUploadConfirmation:uploadFields[i].cancelConfirm, dictRemoveFile:uploadFields[i].remove,dictMaxFilesExceeded:uploadFields[i].maxFilesExceeded,resizeMethod:"contain",resizeWidth:uploadFields[i].resizeWidth,resizeHeight:uploadFields[i].resizeHeight,thumbnailWidth:60,thumbnailHeight:60,timeout:uploadFields[i].timeout,previewTemplate:filePreviewHTML(uploadFields[i]),acceptedFiles:uploadFields[i].acceptedFiles,fallback:function(){jQuery(this.element).closest("form").removeClass("frm_ajax_submit")},init:function(){var hidden=field.parent().find(".dz-hidden-input"); if(typeof hidden.attr("id")==="undefined")hidden.attr("id",uploadFields[i].label);this.on("sending",function(file,xhr,formData){if(!anyPrecedingRequiredFieldsCompleted(uploadFields[i],selector)){this.removeFile(file);alert(frm_js.empty_fields);return false}else if(isSpam(uploadFields[i].parentFormID)){this.removeFile(file);alert(frm_js.file_spam);return false}else{formData.append("action","frm_submit_dropzone");formData.append("field_id",uploadFields[i].fieldID);formData.append("form_id",uploadFields[i].formID); formData.append("nonce",frm_js.nonce)}});this.on("success",function(file,response){var mediaIDs=jQuery.parseJSON(response);for(var m=0;m'+ file.name+""}}});this.on("addedfile",function(){processesRunning++;frmFrontForm.showSubmitLoading(form)});this.on("removedfile",function(file){var fileCount=this.files.length;if(this.options.uploadMultiple===false&&fileCount<1)this.enable();if(file.accepted!==false&&uploadFields[i].uploadMultiple!==true)jQuery('input[name="'+fieldName+'"]').val("");if(file.accepted!==false&&typeof file.mediaID!=="undefined"){jQuery(file.previewElement).remove();fileCount=this.files.length;this.options.maxFiles= uploadFields[i].maxFiles-fileCount}});if(typeof uploadFields[i].mockFiles!=="undefined")for(var f=0;f\n'+ '
\n'+'
\n'+'
\n'+'
\n'+'
\n'+''+"
\n"+'
\n'+'
\n'+ "
\n"+"
"}function getHiddenUploadHTML(field,mediaID,fieldName){return''}function removeFile(){var fieldName=jQuery(this).data("frm-remove");fadeOut(jQuery(this).closest(".dz-preview"));var singleField=jQuery('input[name="'+fieldName+'"]');if(singleField.length)singleField.val("")}function isSpam(formID){if(isHoneypotSpam(formID)||isHeadless())return true;else return false}function isHoneypotSpam(formID){var val= document.getElementById("frm_verify_"+formID).value;return val!==""}function isHeadless(){return window._phantom||window.callPhantom||window.__phantomas||window.Buffer||window.emit||window.spawn}function anyPrecedingRequiredFieldsCompleted(uploadField,fileSelector){var prevPage,requiredFields,fieldsComplete=true,dropzoneDiv=jQuery(fileSelector),form=dropzoneDiv.closest("form");if(form.length<1)return false;prevPage=form.find('input[name="frm_prev_page"]');if(prevPage.length)return true;requiredFields= jQuery(form).find(".frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea, "+fileSelector);if(requiredFields.length<1)return true;else{for(var r=0,rl=requiredFields.length;r-1||requiredFields[r].getAttribute("data-frmfile")!==null)continue;if(frmFrontForm.checkRequiredField(requiredFields[r],[]).length<1){fieldsComplete=true;break}else fieldsComplete= false}return fieldsComplete}}function showOtherText(){var type=this.type,other=false,select=false;if(type==="select-one"){select=true;var curOpt=this.options[this.selectedIndex];if(typeof curOpt!=="undefined"&&curOpt.className==="frm_other_trigger")other=true}else if(type==="select-multiple"){select=true;var allOpts=this.options;other=false;for(var i=0;i-1)originalEvent="value changed";else originalEvent="other";return originalEvent}function checkFieldsWithConditionalLogicDependentOnThis(fieldId,changedInput){if(typeof __FRMRULES==="undefined"||typeof __FRMRULES[fieldId]==="undefined"||__FRMRULES[fieldId].dependents.length<1||changedInput===null||typeof changedInput==="undefined")return;var triggerFieldArgs=__FRMRULES[fieldId];var repeatArgs=getRepeatArgsFromFieldName(changedInput[0].name); for(var i=0,l=triggerFieldArgs.dependents.length;id},"<=":function(c,d){return c>=d},">":function(c,d){return c=":function(c,d){return c<=d},"LIKE":function(c,d){if(!d)return false;c=prepareLogicValueForLikeComparison(c);d=prepareEnteredValueForLikeComparison(c,d);return d.indexOf(c)!=-1},"not LIKE":function(c,d){if(!d)return true; c=prepareLogicValueForLikeComparison(c);d=prepareEnteredValueForLikeComparison(c,d);return d.indexOf(c)==-1}};return theOperators[op](a,b)}function prepareLogicValueForComparison(a){if(String(a).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/)!==-1)a=parseFloat(a);else if(typeof a==="string")a=a.trim();return a}function prepareEnteredValueForComparison(a,b){if(typeof b==="undefined"||b===null||b===false)b="";if(jQuery.isArray(b)&&jQuery.inArray(String(a),b)>-1)b=a;if(typeof a==="number"&&typeof b==="string")b=parseFloat(b);if(typeof b==="string")b=b.trim();return b}function prepareLogicValueForLikeComparison(val){return prepareValueForLikeComparison(val)}function prepareEnteredValueForLikeComparison(logicValue,enteredValue){enteredValue=prepareValueForLikeComparison(enteredValue);var currentValue="";if(jQuery.isArray(enteredValue))for(var i=0,l=enteredValue.length;i-1){enteredValue=logicValue;break}}return enteredValue} function prepareValueForLikeComparison(val){if(typeof val==="string")val=val.toLowerCase();else if(typeof val==="number")val=val.toString();return val}function routeToHideOrShowField(depFieldArgs,logicOutcomes){var onCurrentPage,action=getHideOrShowAction(depFieldArgs,logicOutcomes);if(depFieldArgs.fieldType==="submit")onCurrentPage=isSubmitButtonOnPage(depFieldArgs.containerId);else onCurrentPage=isFieldDivOnPage(depFieldArgs.containerId);if(action=="show")if(depFieldArgs.fieldType==="data"&&depFieldArgs.hasOwnProperty("dataLogic"))updateDynamicField(depFieldArgs, onCurrentPage);else showFieldAndSetValue(depFieldArgs,onCurrentPage);else hideFieldAndClearValue(depFieldArgs,onCurrentPage)}function isFieldDivOnPage(containerId){var fieldDiv=document.getElementById(containerId);return fieldDiv!==null}function isSubmitButtonOnPage(container){var submitButton=document.querySelector("#"+container);return submitButton!=null}function getHideOrShowAction(depFieldArgs,logicOutcomes){if(depFieldArgs.anyAll==="any")if(logicOutcomes.indexOf(true)>-1)action=depFieldArgs.showHide; else action=reverseAction(depFieldArgs.showHide);else if(logicOutcomes.indexOf(false)>-1)action=reverseAction(depFieldArgs.showHide);else action=depFieldArgs.showHide;return action}function reverseAction(action){if(action==="show")action="hide";else action="show";return action}function showFieldAndSetValue(depFieldArgs,onCurrentPage){if(isFieldCurrentlyShown(depFieldArgs.containerId,depFieldArgs.formId))return;removeFromHideFields(depFieldArgs.containerId,depFieldArgs.formId);if(depFieldArgs.fieldType==="submit"){if(onCurrentPage)showOrEnableSubmitButton(depFieldArgs);return}if(onCurrentPage){setValuesInsideFieldOnPage(depFieldArgs.containerId,depFieldArgs);showFieldContainer(depFieldArgs.containerId)}else setValuesInsideFieldAcrossPage(depFieldArgs)}function showOrEnableSubmitButton(depFieldArgs){if(depFieldArgs.hideDisable&&depFieldArgs.hideDisable==="disable")enableButton("#"+depFieldArgs.containerId);else showFieldContainer(depFieldArgs.containerId);removeSubmitButtonFromHiddenList(depFieldArgs)} function removeSubmitButtonFromHiddenList(depFieldArgs){hiddenSubmitButtons=hiddenSubmitButtons.filter(function(button){return button!==depFieldArgs.formKey})}function enableButton(buttonSelector){jQuery(buttonSelector).prop("disabled",false)}function setValuesInsideFieldOnPage(container,depFieldArgs){var inputs=getInputsInFieldOnPage(container),inContainer=depFieldArgs.fieldType==="divider"||depFieldArgs.fieldType==="form";setValueForInputs(inputs,inContainer,depFieldArgs.formId,"required")}function setValuesInsideFieldAcrossPage(depFieldArgs){var inputs= getInputsInFieldAcrossPage(depFieldArgs),inContainer=depFieldArgs.fieldType==="divider"||depFieldArgs.fieldType==="form";setValueForInputs(inputs,inContainer,depFieldArgs.formId)}function getInputsInFieldOnPage(containerId){var container=document.getElementById(containerId);return container.querySelectorAll('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]')}function getInputsInFieldAcrossPage(depFieldArgs){var inputs=[];if(depFieldArgs.fieldType==="divider")inputs= getInputsInHiddenSection(depFieldArgs);else if(depFieldArgs.fieldType==="form")inputs=getInputsInHiddenEmbeddedForm(depFieldArgs);else inputs=getHiddenInputs(depFieldArgs);return inputs}function getHiddenInputs(depFieldArgs){var name="";if(depFieldArgs.isRepeating){var containerFieldId=getContainerFieldId(depFieldArgs);name="item_meta["+containerFieldId+"]["+depFieldArgs.repeatRow+"]["+depFieldArgs.fieldId+"]"}else name="item_meta["+depFieldArgs.fieldId+"]";return document.querySelectorAll('[name^="'+ name+'"]')}function setValueForInputs(inputs,inContainer,formId,setRequired){if(inputs.length){var prevInput;for(var i=0;i-1&&is_optional===-1)input.setAttribute("aria-required",true)}function skipSetValue(i,prevInput,inputs){var typeArray=["checkbox","radio"];if(i<1||typeof prevInput==="undefined")return false;var isOther=inputs[i].className.indexOf("frm_other_input")!==-1;return isOther||prevInput.name==inputs[i].name&& typeArray.indexOf(prevInput.type)>-1}function isChildInputConditionallyHidden(input,formId){var fieldDivPart=frmFrontForm.getFieldId(input,true),fieldDivId="frm_field_"+fieldDivPart+"_container";return isFieldConditionallyHidden(fieldDivId,formId)}function showFieldContainer(containerId){jQuery("#"+containerId).show()}function hideFieldAndClearValue(depFieldArgs,onCurrentPage){if(isFieldConditionallyHidden(depFieldArgs.containerId,depFieldArgs.formId))return;addToHideFields(depFieldArgs.containerId, depFieldArgs.formId);if(depFieldArgs.fieldType==="submit"){if(onCurrentPage)hideOrDisableSubmitButton(depFieldArgs);return}if(onCurrentPage){hideFieldContainer(depFieldArgs.containerId);clearInputsInFieldOnPage(depFieldArgs.containerId)}else clearInputsInFieldAcrossPage(depFieldArgs)}function hideOrDisableSubmitButton(depFieldArgs){if(depFieldArgs.containerId==undefined)depFieldArgs.containerId=getSubmitButtonContainerID(depFieldArgs);addSubmitButtonToHiddenList(depFieldArgs);if(depFieldArgs.hideDisable&& depFieldArgs.hideDisable==="disable")disableButton("#"+depFieldArgs.containerId);else hideFieldContainer(depFieldArgs.containerId)}function addSubmitButtonToHiddenList(depFieldArgs){hiddenSubmitButtons.push(depFieldArgs.formKey)}function isOnPageSubmitButtonHidden(formKey){return hiddenSubmitButtons.indexOf(formKey)!==-1}function hidePreviouslyHiddenSubmitButton(submitContainerID){var formId=submitContainerID.replace("frm_form_","");formId=formId.replace("_container .frm_final_submit","");var depFieldArgs= getRulesForSingleField("submit_"+formId);if(depFieldArgs)hideOrDisableSubmitButton(depFieldArgs)}function getFormKeyFromFormElementID(elementId){return elementId.replace("form_","")}function hideFieldContainer(containerId){jQuery("#"+containerId).hide()}function disableButton(buttonSelector){jQuery(buttonSelector).prop("disabled",true)}function clearInputsInFieldOnPage(containerId){var inputs=getInputsInFieldOnPage(containerId);clearValueForInputs(inputs,"required")}function clearInputsInFieldAcrossPage(depFieldArgs){var inputs= getInputsInFieldAcrossPage(depFieldArgs);clearValueForInputs(inputs)}function getInputsInHiddenSection(depFieldArgs){var inputs=[];if(depFieldArgs.fieldType==="divider")inputs=document.querySelectorAll('[data-sectionid="'+depFieldArgs.fieldId+'"]');return inputs}function getInputsInHiddenEmbeddedForm(depFieldArgs){return document.querySelectorAll('[id^="field_'+depFieldArgs.fieldKey+'-"]')}function clearValueForInputs(inputs,required){if(inputs.length<1)return;var prevInput,blankSelect,valueChanged= true;for(var i=0,l=inputs.length;i-1||inputs[i].name.indexOf("[row_ids]")>-1){prevInput=inputs[i];continue}if(i>0&&prevInput.name!=inputs[i].name&&valueChanged===true)triggerChange(jQuery(prevInput));valueChanged=true;if(inputs[i].type==="radio"||inputs[i].type==="checkbox")inputs[i].checked=false;else if(inputs[i].tagName==="SELECT"){blankSelect=inputs[i].selectedIndex===0&&inputs[i].options[0].text.trim()==="";if(blankSelect||inputs[i].selectedIndex===-1)valueChanged=false;else inputs[i].selectedIndex=-1;var chosenId=inputs[i].id.replace(/[^\w]/g,"_");var autocomplete=document.getElementById(chosenId+"_chosen");if(autocomplete!==null)jQuery(inputs[i]).trigger("chosen:updated")}else if(inputs[i].type==="range")inputs[i].value=0;else if(inputs[i].getAttribute("data-frmprice")!==null)setHiddenProduct(inputs[i]);else inputs[i].value="";if(required==="required"){inputs[i].required=false;inputs[i].setAttribute("aria-required",false)}prevInput=inputs[i]}if(valueChanged===true)triggerChange(jQuery(prevInput))}function isFieldCurrentlyShown(containerId,formId){return isFieldConditionallyHidden(containerId,formId)===false}function isFieldConditionallyHidden(containerId,formId){var hidden=false,hiddenFields=getHiddenFields(formId);if(hiddenFields.indexOf(containerId)>-1)hidden=true;return hidden}function clearHideFields(){var hideFieldInputs=document.querySelectorAll('[id^="frm_hide_fields_"]');clearValueForInputs(hideFieldInputs)}function addToHideFields(htmlFieldId, formId){var hiddenFields=getHiddenFields(formId);if(hiddenFields.indexOf(htmlFieldId)>-1);else{hiddenFields.push(htmlFieldId);hiddenFields=JSON.stringify(hiddenFields);var frmHideFieldsInput=document.getElementById("frm_hide_fields_"+formId);if(frmHideFieldsInput!==null)frmHideFieldsInput.value=hiddenFields}}function getAllHiddenFields(){var formId,i,hiddenFields=[],hideFieldInputs=document.querySelectorAll('*[id^="frm_hide_fields_"]'),formTotal=hideFieldInputs.length;for(i=0;i0)defaultValue=$select.data("frmval")}placeholder=defaultValue;defaultValue=setDropdownPlaceholder(defaultValue, input);if(placeholder!==defaultValue)placeholder=true;if(typeof defaultValue!=="undefined"){var numericKey=new RegExp(/\[\d*\]$/i);if(input.type==="checkbox"||input.type==="radio")setCheckboxOrRadioDefaultValue(input.name,defaultValue);else if(input.type==="hidden"&&input.name.indexOf("[]")>-1)setHiddenCheckboxDefaultValue(input.name,defaultValue);else if(!inContainer&&input.type==="hidden"&&input.name.indexOf("][")>-1&&numericKey.test(input.name))setHiddenCheckboxDefaultValue(input.name.replace(numericKey, ""),defaultValue);else{if(defaultValue.constructor===Object){var addressType=input.getAttribute("name").split("[").slice(-1)[0];if(addressType!==null){addressType=addressType.replace("]","");defaultValue=defaultValue[addressType];if(typeof defaultValue=="undefined")defaultValue=""}}if(typeof defaultValue==="object")defaultValue="["+defaultValue+"]";input.value=defaultValue}if(!placeholder&&input.tagName==="SELECT"){maybeUpdateChosenOptions(input);if(input.value==="")setOtherSelectValue(input,defaultValue)}triggerChange($input)}} function setDropdownPlaceholder(defaultValue,input){var placeholder;if(typeof defaultValue==="undefined"&&input.tagName==="SELECT"){placeholder=input.getAttribute("data-placeholder");if(placeholder!==null)defaultValue=""}return defaultValue}function setCheckboxOrRadioDefaultValue(inputName,defaultValue){var radioInputs=document.getElementsByName(inputName),isSet=false,firstInput=false;if(typeof defaultValue==="object")defaultValue=Object.keys(defaultValue).map(function(key){return defaultValue[key]}); for(var i=0,l=radioInputs.length;i-1){radioInputs[i].checked=true;isSet=true;if(radioInputs[i].type==="radio")break}}if(!isSet&&firstInput!==false)setOtherValueLimited(firstInput, defaultValue)}function setHiddenCheckboxDefaultValue(inputName,defaultValue){var hiddenInputs=jQuery('input[name^="'+inputName+'"]').get();if(typeof defaultValue==="object")defaultValue=Object.keys(defaultValue).map(function(key){return defaultValue[key]});if(jQuery.isArray(defaultValue))for(var i=0,l=defaultValue.length;i-1){hiddenFields.splice(itemIndex,1);hiddenFields=JSON.stringify(hiddenFields);var frmHideFieldsInput=document.getElementById("frm_hide_fields_"+formId);frmHideFieldsInput.value=hiddenFields}}function checkFieldsWatchingLookup(fieldId,changedInput,originalEvent){if(typeof __FRMLOOKUP==="undefined"||typeof __FRMLOOKUP[fieldId]==="undefined"||__FRMLOOKUP[fieldId].dependents.length<1||changedInput===null||typeof changedInput==="undefined")return;var triggerFieldArgs=__FRMLOOKUP[fieldId];var parentRepeatArgs=getRepeatArgsFromFieldName(changedInput[0].name);for(var i=0,l=triggerFieldArgs.dependents.length;i-1&&jQuery().chosen)jQuery(childSelect).trigger("chosen:updated")}function disableLookup(childSelect){childSelect.className= childSelect.className+" frm_loading_lookup";childSelect.disabled=true;maybeUpdateChosenOptions(childSelect)}function disableFormPreLookup(formId){processesRunning++;if(processesRunning===1){var form=getFormById(formId);if(form!==null)frmFrontForm.showSubmitLoading(jQuery(form))}}function enableFormAfterLookup(formId){processesRunning--;if(processesRunning<=0){var form=getFormById(formId);if(form!==null)frmFrontForm.removeSubmitLoading(jQuery(form),"enable",processesRunning)}}function getFormById(formId){var form= document.querySelector("#frm_form_"+formId+"_container form");if(form===null){form=document.getElementById("frm_form_"+formId+"_container");if(form!==null)form=form.closest("form")}return form}function enableLookup(childSelect,isReadOnly){if(isReadOnly===false)childSelect.disabled=false;childSelect.className=childSelect.className.replace(" frm_loading_lookup","")}function replaceSelectLookupFieldOptions(fieldArgs,childSelect,newOptions){var origVal=childSelect.value;for(var i=childSelect.options.length;i> 0;i--)childSelect.remove(i);var optsLength=newOptions.length;for(i=0;i0}function addLookupToQueueOfTwo(childFieldArgs,childInput){var elementId=childInput.id;if(elementId in lookupQueues){if(lookupQueues[elementId].length>=2)lookupQueues[elementId]=lookupQueues[elementId].slice(0,1)}else lookupQueues[elementId]=[];lookupQueues[elementId].push({childFieldArgs:childFieldArgs,childInput:childInput})}function checkQueueAfterLookupCompleted(elementId){removeLookupFromQueue(elementId);doNextItemInLookupQueue(elementId)}function removeLookupFromQueue(elementId){lookupQueues[elementId].shift()} function doNextItemInLookupQueue(elementId){if(currentLookupHasQueue(elementId)){var childFieldArgs=lookupQueues[elementId][0].childFieldArgs,childInput=lookupQueues[elementId][0].childInput;maybeInsertValueInFieldWatchingLookup(childFieldArgs,childInput)}}function decodeEntities(string){var decoded=string.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'");return decoded}function insertValueInFieldWatchingLookup(fieldKey,childInput,newValue){childInput.value= decodeEntities(newValue);triggerChange(jQuery(childInput),fieldKey)}function addRepeatRowForInput(fieldName,childFieldArgs){var repeatArgs=getRepeatArgsFromFieldName(fieldName);if(repeatArgs.repeatRow!=="")childFieldArgs.repeatRow=repeatArgs.repeatRow;else childFieldArgs.repeatRow=""}function updateDynamicField(depFieldArgs,onCurrentPage){var depFieldArgsCopy=cloneObjectForDynamicFields(depFieldArgs);if(depFieldArgsCopy.inputType==="data")updateDynamicListData(depFieldArgsCopy,onCurrentPage);else if(onCurrentPage)updateDynamicFieldOptions(depFieldArgsCopy)} function cloneObjectForDynamicFields(depFieldArgs){var dataLogic={actualValue:depFieldArgs.dataLogic.actualValue,fieldId:depFieldArgs.dataLogic.fieldId};var dynamicFieldArgs={fieldId:depFieldArgs.fieldId,fieldKey:depFieldArgs.fieldKey,formId:depFieldArgs.formId,containerId:depFieldArgs.containerId,repeatRow:depFieldArgs.repeatRow,dataLogic:dataLogic,children:"",inputType:depFieldArgs.inputType};return dynamicFieldArgs}function updateDynamicListData(depFieldArgs,onCurrentPage){if(onCurrentPage){var $fieldDiv= jQuery("#"+depFieldArgs.containerId);addLoadingIcon($fieldDiv)}jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:depFieldArgs.dataLogic.actualValue,current_field:depFieldArgs.fieldId,hide_id:depFieldArgs.containerId,on_current_page:onCurrentPage,nonce:frm_js.nonce},success:function(html){if(onCurrentPage){var $optContainer=$fieldDiv.find(".frm_opt_container, .frm_data_container");$optContainer.html(html);var $listInputs=$optContainer.children("input");var listVal= $listInputs.val();removeLoadingIcon($optContainer);if(html===""||listVal==="")hideDynamicField(depFieldArgs);else showDynamicField(depFieldArgs,$fieldDiv,$listInputs,true)}else updateHiddenDynamicListField(depFieldArgs,html)}})}function updateDynamicFieldOptions(depFieldArgs,fieldElement){var $fieldDiv=jQuery("#"+depFieldArgs.containerId),$fieldInputs=$fieldDiv.find('select[name^="item_meta"], input[name^="item_meta"]'),prevValue=getFieldValueFromInputs($fieldInputs),defaultVal=$fieldInputs.data("frmval"), editingEntry=$fieldDiv.closest("form").find('input[name="id"]').val();addLoadingIcon($fieldDiv);jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_data_options",trigger_field_id:depFieldArgs.dataLogic.fieldId,entry_id:depFieldArgs.dataLogic.actualValue,field_id:depFieldArgs.fieldId,default_value:defaultVal,container_id:depFieldArgs.containerId,editing_entry:editingEntry,prev_val:prevValue,nonce:frm_js.nonce},success:function(html){var $optContainer=$fieldDiv.find(".frm_opt_container, .frm_data_container"); $optContainer.html(html);var $dynamicFieldInputs=$optContainer.find('select, input[type="checkbox"], input[type="radio"]');removeLoadingIcon($optContainer);if(html===""||$dynamicFieldInputs.length<1)hideDynamicField(depFieldArgs);else{var valueChanged=dynamicFieldValueChanged(depFieldArgs,$dynamicFieldInputs,prevValue);showDynamicField(depFieldArgs,$fieldDiv,$dynamicFieldInputs,valueChanged)}}})}function dynamicFieldValueChanged(depFieldArgs,$dynamicFieldInputs,prevValue){var newValue=getFieldValueFromInputs($dynamicFieldInputs); return prevValue!==newValue}function updateHiddenDynamicListField(depFieldArgs,newValue){var inputId="field_"+depFieldArgs.fieldKey;if(depFieldArgs.repeatRow!=="")inputId+="-"+depFieldArgs.repeatRow;var listInput=document.getElementById(inputId);if(listInput===null)return;listInput.value=newValue;if(isFieldConditionallyHidden(depFieldArgs.containerId,depFieldArgs.formId))removeFromHideFields(depFieldArgs.containerId,depFieldArgs.formId);triggerChange(jQuery(listInput))}function addLoadingIcon($fieldDiv){var currentHTML= $fieldDiv.html();if(currentHTML.indexOf("frm-loading-img")>-1);else{var loadingIcon='';$fieldDiv.html(currentHTML+loadingIcon);var $optContainer=$fieldDiv.find(".frm_opt_container, .frm_data_container");$optContainer.hide()}}function addLoadingIconJS(fieldDiv,optContainer){var currentHTML=fieldDiv.innerHTML;if(currentHTML.indexOf("frm-loading-img")>-1);else{optContainer.style.display="none";var loadingIcon=document.createElement("span");loadingIcon.setAttribute("class", "frm-loading-img");fieldDiv.insertBefore(loadingIcon,optContainer.nextSibling)}}function removeLoadingIcon($optContainer){$optContainer.parent().children(".frm-loading-img").remove();$optContainer.show()}function removeLoadingIconJS(fieldDiv,optContainer){var loadingIcon=fieldDiv.getElementsByClassName("frm-loading-img")[0];if(loadingIcon!==null&&loadingIcon!==undefined)loadingIcon.parentNode.removeChild(loadingIcon);optContainer.style.display="block"}function getFieldValueFromInputs($inputs){var fieldValue= [],currentValue="";$inputs.each(function(){currentValue=this.value;if(this.type==="radio"||this.type==="checkbox"){if(this.checked===true)fieldValue.push(currentValue)}else if(currentValue!=="")fieldValue.push(currentValue)});if(fieldValue.length===0)fieldValue="";return fieldValue}function hideDynamicField(depFieldArgs){hideFieldAndClearValue(depFieldArgs,true)}function showDynamicField(depFieldArgs,$fieldDiv,$fieldInputs,valueChanged){if(isFieldConditionallyHidden(depFieldArgs.containerId,depFieldArgs.formId)){removeFromHideFields(depFieldArgs.containerId, depFieldArgs.formId);$fieldDiv.show()}if($fieldInputs.hasClass("frm_chzn"))loadChosen();if(valueChanged===true)triggerChange($fieldInputs)}function triggerCalc(){if(typeof __FRMCALC==="undefined")return;var triggers=__FRMCALC.triggers;if(triggers)jQuery(triggers.join()).trigger({type:"change",selfTriggered:true});triggerCalcWithoutFields()}function triggerCalcWithoutFields(){var calcs=__FRMCALC.calc,vals=[];for(var fieldKey in calcs)if(calcs[fieldKey].fields.length<1){var totalField=document.getElementById("field_"+ fieldKey);if(totalField!==null&&!isChildInputConditionallyHidden(totalField,calcs[fieldKey].form_id))doSingleCalculation(__FRMCALC,fieldKey,vals)}}function doCalculation(fieldId,triggerField){if(typeof __FRMCALC==="undefined")return;var allCalcs=__FRMCALC,calc=allCalcs.fields[fieldId],vals=[];if(typeof calc==="undefined")return;var keys=calc.total;var len=keys.length;var pages=getStartEndPage(allCalcs.calc[keys[0]]);for(var i=0,l=len;i0)pages.start=hasPreviousPage[0];if(hasAnotherPage!==null)pages.end=hasAnotherPage;return pages}function closest(el,fn){return el&&(fn(el)?el:closest(el.parentNode,fn))}function isTotalFieldOnPage(calcDetails,pages){if(typeof pages.start!=="undefined"||typeof pages.end!=="undefined"){var hiddenTotalField=jQuery('input[type=hidden][name*="['+calcDetails.field_id+']"]');if(hiddenTotalField.length)return isHiddenTotalOnPage(hiddenTotalField,pages)}return true}function isHiddenTotalOnPage(hiddenTotalField,pages){var onPage,hiddenParent=hiddenTotalField.closest(".frm_form_field");if(hiddenParent.length)return true;var totalPos=hiddenTotalField.index();var isAfterStart=true;var isBeforeEnd=true;if(typeof pages.start!=="undefined")isAfterStart= jQuery(pages.start).index()totalPos;onPage=isAfterStart&&isBeforeEnd;if(!onPage)onPage=hiddenTotalField.closest(".do-calculation").length>0;return onPage}function isTotalFieldConditionallyHidden(calcDetails,triggerFieldName){var hidden=false,fieldId=calcDetails.field_id,formId=calcDetails.form_id,hiddenFields=getHiddenFields(formId);if(hiddenFields.length<1)return hidden;if(calcDetails.inSection==="0"&&calcDetails.inEmbedForm==="0")hidden=isNonRepeatingFieldConditionallyHidden(fieldId,hiddenFields);else{var repeatArgs=getRepeatArgsFromFieldName(triggerFieldName);if(isNonRepeatingFieldConditionallyHidden(fieldId,hiddenFields))hidden=true;else if(isRepeatingFieldConditionallyHidden(fieldId,repeatArgs,hiddenFields))hidden=true;else if(calcDetails.inSection!=="0"&&calcDetails.inEmbedForm!=="0")hidden=isRepeatingFieldConditionallyHidden(calcDetails.inSection,repeatArgs,hiddenFields);else if(calcDetails.inSection!=="0")hidden= isNonRepeatingFieldConditionallyHidden(calcDetails.inSection,hiddenFields);else if(calcDetails.inEmbedForm!=="0")hidden=isNonRepeatingFieldConditionallyHidden(calcDetails.inEmbedForm,hiddenFields)}return hidden}function isNonRepeatingFieldConditionallyHidden(fieldId,hiddenFields){var htmlID="frm_field_"+fieldId+"_container";return hiddenFields.indexOf(htmlID)>-1}function isRepeatingFieldConditionallyHidden(fieldId,repeatArgs,hiddenFields){var hidden=false;if(repeatArgs.repeatingSection){var fieldRepeatId= "frm_field_"+fieldId+"-"+repeatArgs.repeatingSection;fieldRepeatId+="-"+repeatArgs.repeatRow+"_container";hidden=hiddenFields.indexOf(fieldRepeatId)>-1}return hidden}function maybeShowCalculationsErrorAlert(err,fieldKey,thisFullCalc){var alertMessage="";if(!jQuery("form").hasClass("frm-admin-viewing"))return;alertMessage+=frm_js.calc_error+" "+fieldKey+":\n\n";alertMessage+=thisFullCalc+"\n\n";if(err.message)alertMessage+=err.message+"\n\n";alert(alertMessage)}function treatAsUTC(date){var copy=new Date(date.valueOf()); copy.setMinutes(copy.getMinutes()-copy.getTimezoneOffset());return copy}function normalizeDate(date){switch(typeof date){case "number":return new Date(date*864E5);case "string":return new Date(date);default:return date}}function calculateDateDifference(a,b,format){a=normalizeDate(a);b=normalizeDate(b);switch(format){case "days":{return Math.floor((treatAsUTC(b)-treatAsUTC(a))/864E5)}case "years":default:{var years=b.getFullYear()-a.getFullYear();if(b.getMonth()-1){var calcParts=thisFullCalc.split(").toFixed(");if(isNumeric(calcParts[1])){dec=calcParts[1];thisFullCalc=thisFullCalc.replace(").toFixed("+dec,"")}}thisFullCalc=trimNumericCalculation(thisFullCalc); if(thisFullCalc!=="")try{total=parseFloat(eval(thisFullCalc))}catch(err){maybeShowCalculationsErrorAlert(err,fieldKey,thisFullCalc)}if(typeof total==="undefined"||isNaN(total))total=0;if(isNumeric(dec)&&total!=="")total=total.toFixed(dec)}if(thisCalc.is_currency===true&&isNumeric(total)){currency=getCurrency(thisCalc.form_id);if(currency.decimals>0){total=Math.round10(total,currency.decimals);total=maybeAddTrailingZeroToPrice(total,currency);dec=currency.decimals}}if(totalField.val()===total){setDisplayedTotal(totalField, total,currency);return}updatedTotal=false;if((isNumeric(dec)||thisCalc.is_currency)&&["number","text"].indexOf(totalField.attr("type"))>-1){if(total.toString().slice(-1)=="0"&&navigator.userAgent.toLowerCase().indexOf("firefox")>-1)totalField[0].setAttribute("type","text");if(totalField.parent().is(".frm_input_group.frm_with_box.frm_hidden")){updatedTotal=true;totalField.val(total.replace(",","."))}}if(!updatedTotal)totalField.val(total);if(triggerField===null||typeof triggerField==="undefined"|| totalField.attr("name")!=triggerField.attr("name"))triggerChange(totalField,fieldKey);setDisplayedTotal(totalField,total,currency)}function setDisplayedTotal(totalField,total,currency){var prepend,append,showTotal=totalField.parent().prev();if(!showTotal.hasClass("frm_total_formatted"))return;prepend=showTotal.data("prepend");append=showTotal.data("append");if(typeof prepend==="undefined")prepend="";if(typeof append==="undefined")append="";if(typeof currency==="object"){total=formatCurrency(total, currency);if(currency.symbol_left===prepend)prepend="";if(currency.symbol_right===append)append=""}if(prepend!=="")prepend=''+prepend+"";if(append!=="")append=''+append+"";showTotal.html(prepend+''+total+""+append)}function getValsForSingleCalc(thisCalc,thisFullCalc,allCalcs,vals,fieldInfo){var fCount=thisCalc.fields.length;for(var f=0,c=fCount;f=3}function getCalcFieldId(field,allCalcs,vals){if(typeof vals[field.valKey]!=="undefined"&&vals[field.valKey]!==0)return vals;vals[field.valKey]=0;var currency,calcField=getCalcField(field);if(calcField===false)return vals;calcField.each(function(){var thisVal=getOptionValue(field.thisField,this);if(field.thisField.type==="date"){var d=getDateFieldValue(allCalcs.date,thisVal);if(d!==null)vals[field.valKey]=Math.ceil(d/(1E3*60*60*24))}else if(this.hasAttribute("data-frmprice")||field.thisField.type==="total"){currency=getCurrency(field.formID);vals[field.valKey]+=parseFloat(!currency?thisVal:preparePrice(thisVal, currency))}else{var n=thisVal;if(n!==""&&n!==0){n=n.trim();n=parseFloat(n.replace(/,/g,"").match(/-?[\d\.]+$/))}if(typeof n==="undefined"||isNaN(n)||n==="")n=0;vals[field.valKey]+=n}});return vals}function getTextCalcFieldId(field,vals){if(typeof vals[field.valKey]!=="undefined"&&vals[field.valKey]!=="")return vals;vals[field.valKey]="";var calcField=getCalcField(field);if(calcField===false)return vals;var count=0;var sep="";calcField.each(function(){var thisVal=getOptionValue(field.thisField,this); thisVal=thisVal.trim();sep=getCalcSep(field,count);if(thisVal!==""){vals[field.valKey]+=sep+thisVal;count++}});return vals}function getCalcSep(field,count){var sep="";if(count>0){if(field.thisField.type==="time")if(count==1)sep=":";else{if(count==2)sep=" "}else sep=", ";var customSep=jQuery(document).triggerHandler("frmCalSeparation",[field.thisField,count]);if(typeof customSep!=="undefined")sep=customSep}return sep}function getCalcField(field){var calcField;if(field.inSection===false)calcField=jQuery(field.thisFieldCall); else calcField=getSiblingField(field);if(calcField===null||typeof calcField==="undefined"||calcField.length<1)calcField=false;return calcField}function getDateFieldValue(dateFormat,thisVal){var d=0;if(!thisVal);else if(typeof jQuery.datepicker==="undefined"){var splitAt="-";if(dateFormat.indexOf("/")>-1)splitAt="/";var year="",month="",day="",formatPieces=dateFormat.split(splitAt),datePieces=thisVal.split(splitAt);for(var i=0;icurrentYearPlusFifteen)year="19"+datePieces[i];else year="20"+datePieces[i]}else if(formatPieces[i]==="yy")year=datePieces[i];else if(formatPieces[i]==="m"||formatPieces[i]==="mm"){month=datePieces[i];if(month.length<2)month="0"+month}else if(formatPieces[i]==="d"||formatPieces[i]==="dd"){day=datePieces[i];if(day.length<2)day="0"+day}d=Date.parse(year+"-"+month+"-"+day)}else d=jQuery.datepicker.parseDate(dateFormat, thisVal);return d}function getSiblingField(field){if(typeof field.triggerField==="undefined")return null;var fields=null,container=field.triggerField.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid"),repeatArgs=getRepeatArgsFromFieldName(field.triggerField.attr("name")),siblingFieldCall=field.thisFieldCall.replace("[id=","[id^=").replace(/-"]/g,"-"+repeatArgs.repeatRow+'"]');if(container.length||repeatArgs.repeatRow!==""){if(container.length)fields=container.find(siblingFieldCall); else fields=jQuery(siblingFieldCall);if(fields===null||typeof fields==="undefined"||fields.length<1)fields=uncheckedSiblingOrOutsideSection(field,container,siblingFieldCall)}else fields=getNonSiblingField(field);return fields}function uncheckedSiblingOrOutsideSection(field,container,siblingFieldCall){var fields=null;if(siblingFieldCall.indexOf(":checked")){var inSection=container.find(siblingFieldCall.replace(":checked",""));if(inSection.length<1)fields=getNonSiblingField(field)}else fields=getNonSiblingField(field); return fields}function getNonSiblingField(field){return jQuery(field.thisFieldCall)}function getOptionValue(thisField,currentOpt){var thisVal;if(isOtherOption(thisField,currentOpt))thisVal=getOtherValueAnyField(thisField,currentOpt);else if(currentOpt.type==="checkbox"||currentOpt.type==="radio")if(currentOpt.checked)thisVal=currentOpt.hasAttribute("data-frmprice")?currentOpt.dataset.frmprice:currentOpt.value;else thisVal=currentOpt.dataset.off;else thisVal=currentOpt.hasAttribute("data-frmprice")? currentOpt.dataset.frmprice:jQuery(currentOpt).val();if(typeof thisVal==="undefined")thisVal="";return thisVal}function isOtherOption(thisField,currentOpt){var isOtherOpt=false;if(currentOpt.type==="hidden"){if(getOtherValueLimited(currentOpt)!=="")isOtherOpt=true}else if(thisField.type==="select"){var optClass=currentOpt.className;if(optClass&&optClass.indexOf("frm_other_trigger")>-1)isOtherOpt=true}else if(thisField.type==="checkbox"||thisField.type==="radio")if(currentOpt.id.indexOf("-other_")> -1&¤tOpt.id.indexOf("-otext")<0)isOtherOpt=true;return isOtherOpt}function getOtherValueLimited(currentOpt){var otherVal="",otherText=document.getElementById(currentOpt.id+"-otext");if(otherText!==null&&otherText.value!=="")otherVal=otherText.value;return otherVal}function getOtherValueAnyField(thisField,currentOpt){var otherVal=0;if(thisField.type==="select")if(currentOpt.type==="hidden")if(isCurrentOptRepeating(currentOpt));else otherVal=getOtherValueLimited(currentOpt);else otherVal=getOtherSelectValue(currentOpt); else if(thisField.type==="checkbox"||thisField.type==="radio")if(currentOpt.type==="hidden");else otherVal=getOtherValueLimited(currentOpt);return otherVal}function isCurrentOptRepeating(currentOpt){var isRepeating=false,parts=currentOpt.name.split("[");if(parts.length>2)isRepeating=true;return isRepeating}function getOtherSelectValue(currentOpt){var fields=getOtherSelects(currentOpt);return fields.val()}function setOtherSelectValue(thisField,value){var i,fields=getOtherSelects(thisField);if(fields.length< 1)return;fields.val(value);for(i=0;i0)for(i=0;i'+opts.options.edit_link+"");else data.setCell(row,col,"");col++}if(showDelete)if(typeof entry.deleteLink!=="undefined")data.setCell(row,col,''+opts.options.delete_link+"");else data.setCell(row,col,"");row++}}else{data.addRows(1);col=0;for(i=0,l=colCount;i< l;i++){if(col>0)data.setCell(0,col,"");else data.setCell(0,col,opts.options.no_entries);col++}}var chart=new google.visualization.Table(document.getElementById("frm_google_table_"+opts.options.form_id));chart.draw(data,opts.graphOpts)}function generateGoogleGraphs(graphs){for(var i=0,l=graphs.length;i0){var lastRowIndex=jQuery(".frm_repeat_"+id+":last").attr("id").replace("frm_section_"+id+"-","");if(lastRowIndex.indexOf("i")>-1)i=1;else i=1+parseInt(lastRowIndex)}jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_add_form_row",field_id:id,i:i,numberOfSections:numberOfSections,nonce:frm_js.nonce},success:function(r){if(r.html){var html= r.html;var item=jQuery(html).addClass("frm-fade-in");thisBtn.parents(".frm_section_heading").append(item);if(r.is_repeat_limit_reached)hideAddButton(id);var checked=["other"];var fieldID,fieldObject;var reset="reset";var repeatArgs={repeatingSection:id.toString(),repeatRow:i.toString()};jQuery(html).find("input, select, textarea").each(function(){if(this.name==="")return true;if(this.type=="file")fieldID=this.name.replace("file","").split("-")[0];else fieldID=this.name.replace("item_meta[","").split("]")[2].replace("[", "");if(jQuery.inArray(fieldID,checked)==-1){if(this.id===false||this.id==="")return;fieldObject=jQuery("#"+this.id);checked.push(fieldID);hideOrShowFieldById(fieldID,repeatArgs);updateWatchingFieldById(fieldID,repeatArgs,"value changed");checkFieldsWithConditionalLogicDependentOnThis(fieldID,fieldObject);checkFieldsWatchingLookup(fieldID,fieldObject,"value changed");doCalculation(fieldID,fieldObject);reset="persist"}});jQuery(html).find(".frm_html_container").each(function(){var fieldID=this.id.replace("frm_field_", "").split("-")[0];checked.push(fieldID);hideOrShowFieldById(fieldID,repeatArgs)});loadDropzones(repeatArgs.repeatRow);loadSliders();loadChosen();jQuery(html).find(".frm_html_container").each(function(){var fieldID=this.id.replace("frm_field_","").split("-")[0];checked.push(fieldID);hideOrShowFieldById(fieldID,repeatArgs)});jQuery(html).find(".wp-editor-area").each(function(){initRichText(this.id)})}if(typeof frmThemeOverride_frmAddRow=="function")frmThemeOverride_frmAddRow(id,r);jQuery(document).trigger("frmAfterAddRow"); jQuery(".frm_repeat_"+id).each(function(i){this.style.zIndex=999-i});currentlyAddingRow=false},error:function(){currentlyAddingRow=false}});return false}function removeRichText(id){tinymce.EditorManager.execCommand ("mceRemoveEditor",true,id)}function initRichText(id){var key=Object.keys(tinyMCEPreInit.mceInit)[0],orgSettings=tinyMCEPreInit.mceInit[key],newValues={selector:"#"+id,body_class:orgSettings.body_class.replace(key,id)},newSettings=Object.assign({},orgSettings,newValues);tinymce.init(newSettings)} function editEntry(){var $edit=jQuery(this),entryId=$edit.data("entryid"),prefix=$edit.data("prefix"),postId=$edit.data("pageid"),formId=$edit.data("formid"),cancel=$edit.data("cancel"),fields=$edit.data("fields"),excludeFields=$edit.data("excludefields"),$cont=jQuery(document.getElementById(prefix+entryId)),orig=$cont.html();$cont.html('");jQuery.ajax({type:"POST",url:frm_js.ajax_url, dataType:"html",data:{action:"frm_entries_edit_entry_ajax",post_id:postId,entry_id:entryId,id:formId,nonce:frm_js.nonce,fields:fields,exclude_fields:excludeFields},success:function(html){$cont.children(".frm-loading-img").replaceWith(html);$edit.removeClass("frm_inplace_edit").addClass("frm_cancel_edit");$edit.html(cancel);checkConditionalLogic("editInPlace");if(typeof frmFrontForm.fieldValueChanged==="function")jQuery(document).on("change",'.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]', frmFrontForm.fieldValueChanged);checkFieldsOnPage(prefix+entryId)}});return false}function cancelEdit(){var $cancelLink=jQuery(this),prefix=$cancelLink.data("prefix"),entryId=$cancelLink.data("entryid"),$cont=jQuery(document.getElementById(prefix+entryId));$cont.children(".frm_forms").replaceWith("");$cont.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content");switchCancelToEdit($cancelLink)}function switchCancelToEdit($link){var label=$link.data("edit");$link.removeClass("frm_cancel_edit").addClass("frm_inplace_edit"); $link.html(label)}function deleteEntry(){var $link=jQuery(this),confirmText=$link.data("deleteconfirm");if(confirm(confirmText)){var entryId=$link.data("entryid"),prefix=$link.data("prefix");$link.replaceWith('');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:entryId,nonce:frm_js.nonce},success:function(html){if(html.replace(/^\s+|\s+$/g,"")==="success"){var container=jQuery(document.getElementById(prefix+ entryId));container.fadeOut("slow",function(){container.remove()});jQuery(document.getElementById("frm_delete_"+entryId)).fadeOut("slow");jQuery(document).trigger("frmEntryDeleted",[entryId])}else jQuery(document.getElementById("frm_delete_"+entryId)).replaceWith(html)}})}return false}function doEditInPlaceCleanUp(form){var entryIdField=jQuery(form).find('input[name="id"]');if(entryIdField.length){var link=document.getElementById("frm_edit_"+entryIdField.val());if(isCancelLink(link))switchCancelToEdit(jQuery(link))}} function isCancelLink(link){return link!==null&&link.className.indexOf("frm_cancel_edit")>-1}function loadUniqueTimeFields(){if(typeof __frmUniqueTimes==="undefined")return;var timeFields=__frmUniqueTimes;for(var i=0;i-1)if(selectLabel)stars[i].className+=" star-rating-hover";else stars[i].classList.remove("star-rating-hover", "star-rating-on");else selectLabel=parseInt(stars[i].value)<=current}function unhoverStars(){var input=this.previousSibling,starGroup=input.parentElement;starGroup.classList.remove("frm-star-hovered");var stars=starGroup.childNodes;var selected=jQuery(starGroup).find("input:checked").attr("id");var isSelected="";for(var i=stars.length-1;i>0;i--)if(typeof stars[i].className!=="undefined"&&stars[i].className.indexOf("star-rating")>-1){stars[i].classList.remove("star-rating-hover");if(isSelected===""&& typeof selected!=="undefined"&&stars[i].getAttribute("for")==selected)isSelected=" star-rating-on";if(isSelected!=="")stars[i].className+=isSelected}}function loadSliders(){jQuery(document).on("input change","input[data-frmrange]",function(){var i,c=this.parentNode.children;for(i=0;i1)input=input.eq(0);input.trigger({type:"change",selfTriggered:true,frmTriggered:fieldKey})}function loadCustomInputMasks(){if(typeof __frmMasks==="undefined")return;var maskFields=__frmMasks;for(var i=0;i=0}function checkPasswordField(){var fieldId,fieldIdSplit,checks,split,suffix,check,span; if(this.className.indexOf("frm_strength_meter")>-1){fieldId=this.name.substr(this.name.indexOf("[")+1).replace(/\]\[\d\]\[/,"-");fieldId=fieldId.substr(0,fieldId.length-1);fieldIdSplit=fieldId.split("-");if(fieldIdSplit.length===2)fieldId=fieldIdSplit[1]+"-"+fieldIdSplit[0];checks=passwordChecks();split=this.id.split("-");suffix=split.length>1&&!isNaN(split[split.length-1])?"-"+split[split.length-1]:"";for(check in checks){span=document.getElementById("frm-pass-"+check+"-"+fieldId+suffix);addOrRemoveVerifyPass(checks[check], this.value,span)}}}function passwordChecks(){return{"eight-char":/^.{8,}$/,number:/\d/,uppercase:/[A-Z]/,lowercase:/[a-z]/,"special-char":/(?=.*[^a-zA-Z0-9])/}}function addOrRemoveVerifyPass(regEx,password,span){if(span!==null){var remove=regEx.test(password);if(remove)maybeRemovePassReq(span);else maybeRemovePassVerified(span)}}function maybeRemovePassReq(span){if(span.classList.contains("frm-pass-req")){span.classList.remove("frm-pass-req");span.classList.add("frm-pass-verified")}}function maybeRemovePassVerified(span){if(span.classList.contains("frm-pass-verified")){span.classList.remove("frm-pass-verified"); span.classList.add("frm-pass-req")}}function checkCheckboxSelectionLimit(){var limit=parseInt(this.getAttribute("data-frmlimit")),checked=this.checked;if(!limit)return;var allBoxes=jQuery(this).parents(".frm_opt_container").find('input[type="checkbox"]');if(limit>=allBoxes.length)return;var checkedBoxes=allBoxes.filter(function(){return this.checked});if(checked){if(checkedBoxes.length>=limit)allBoxes.filter(function(){return!this.checked}).attr("disabled","disabled")}else allBoxes.removeAttr("disabled")} function addTopAddRowBtnForRepeater(){jQuery('.frm_section_heading:has(div[class*="frm_repeat_"])').each(function(){var firstRepeatedSection=jQuery(this).find('div[class*="frm_repeat_"]:first');firstRepeatedSection.before(firstRepeatedSection.find(".frm_add_form_row").clone().addClass("frm_hidden"))})}function maybeDisableCheckboxesWithLimit(){jQuery('input[type="checkbox"][data-frmlimit]:not(:checked)').each(function(){var limit=parseInt(this.getAttribute("data-frmlimit"));if(!limit)return;var allBoxes= jQuery(this).parents(".frm_opt_container").find('input[type="checkbox"]');if(limit>=allBoxes.length)return;var checkedBoxes=allBoxes.filter(function(){return this.checked});if(limit>checkedBoxes.length)return;this.setAttribute("disabled","disabled")})}function checkQuantityFieldMinMax(input){var val=parseFloat(input.value?input.value.trim():0),max=input.hasAttribute("max")?parseFloat(input.getAttribute("max")):0,min=input.hasAttribute("min")?parseFloat(input.getAttribute("min")):0;if(isNaN(val))return 0; max=isNaN(max)?0:max;min=isNaN(min)?0:min<0?0:min;if(valmax){input.value=max;return max}return val}function setHiddenProduct(input){input.setAttribute("data-frmhidden","1");triggerChange(jQuery(input))}function setHiddenProductContainer(container){if(container.innerHTML.indexOf("data-frmprice")!==-1)jQuery(container).find("input[data-frmprice], select:has([data-frmprice])").attr("data-frmhidden","1")}function setShownProduct(input){var wasHidden=input.getAttribute("data-frmhidden"); if(wasHidden!==null){input.removeAttribute("data-frmhidden");triggerChange(jQuery(input))}}function calcProductsTotal(e){var formTotals=[],totalFields,leftSymbol,rightSymbol;if(typeof __FRMCURR==="undefined")return;if(undefined!==e&&"undefined"!==typeof e.target&&("keyup"===e.type||"change"===e.type)){var el=e.target;if(el.hasAttribute("data-frmprice")&&el instanceof HTMLInputElement&&"text"===el.type)el.setAttribute("data-frmprice",el.value.trim())}totalFields=jQuery("[data-frmtotal]");if(!totalFields.length)return; totalFields.each(function(){var currency,formId,formatted,total=0,totalField=jQuery(this),$form=totalField.closest("form"),isRepeatingTotal=isRepeatingFieldByName(this.name);if(!$form.length)return;formId=$form.find('input[name="form_id"]').val();currency=getCurrency(formId);if(typeof formTotals[formId]!=="undefined"&&!isRepeatingTotal)total=formTotals[formId];else{$form.find("input[data-frmprice],select:has([data-frmprice])").each(function(){var quantity,$this,price=0,isUserDef=false,isSingle=false; if(isRepeatingTotal&&!isRepeatingWithTotal(this,totalField[0]))return;if(this.hasAttribute("data-frmhigherpg")||isProductFieldHidden(this))return;if(this.tagName==="SELECT"){if(this.selectedIndex!==-1)price=this.options[this.selectedIndex].getAttribute("data-frmprice")}else{isUserDef="text"===this.type;isSingle="hidden"===this.type;$this=jQuery(this);if(!isUserDef&&!isSingle&&!$this.is(":checked"))return;price=this.getAttribute("data-frmprice")}if(!price)price=0;else{price=preparePrice(price,currency); quantity=getQuantity(isUserDef,this);price=parseFloat(quantity)*parseFloat(price)}total+=price});if(!isRepeatingTotal)formTotals[formId]=total}total=isNaN(total)?0:total;currency.decimal_separator=currency.decimal_separator.trim();if(!currency.decimal_separator.length)currency.decimal_separator=".";total=currency.decimals>0?Math.round10(total,currency.decimals):Math.ceil(total);total=maybeAddTrailingZeroToPrice(total,currency);totalField.val(total);triggerChange(totalField);total=formatCurrency(total, currency);formatted=totalField.prev(".frm_total_formatted");if(formatted.length<1)formatted=totalField.closest(".frm_form_field").find(".frm_total_formatted");if(formatted.length)formatted.html(total)})}function formatCurrency(total,currency){var leftSymbol,rightSymbol;total=maybeAddTrailingZeroToPrice(total,currency);total=addThousands(total,currency);leftSymbol=currency.symbol_left+currency.symbol_padding;rightSymbol=currency.symbol_padding+currency.symbol_right;return leftSymbol+total+rightSymbol} function isProductFieldHidden(input){return input.getAttribute("data-frmhidden")!==null}function isRepeatingWithTotal(input,total){var regex=/item_meta\[.+?\]\[.+?\]/;return isRepeatingFieldByName(input.name)&&total.name.match(regex)[0]===input.name.match(regex)[0]}function getCurrency(formId){if(typeof __FRMCURR!=="undefined"&&typeof __FRMCURR[formId]!=="undefined")return __FRMCURR[formId]}function getQuantity(isUserDef,field){var quantity,quantityFields,isRepeating,fieldID,$this=jQuery(field);fieldID= frmFrontForm.getFieldId(field,false);if(!fieldID)return 0;isRepeating=isRepeatingFieldByName(field.name);if(isRepeating){var match=field.name.match(/item_meta\[.+?\]\[.+?\]/);if(null===match)return 0;$this.nameMatch=match[0]}quantity=getQuantityField($this,fieldID,isRepeating);if(quantity)quantity=checkQuantityFieldMinMax(quantity);else{quantityFields=getQuantityFields($this,isRepeating);if(1===quantityFields.length&&""===quantityFields[0].getAttribute("data-frmproduct").trim())quantity=checkQuantityFieldMinMax(quantityFields[0]); else quantity=1}if(0===quantity&&isUserDef)quantity=1;return quantity}function getQuantityField(elementObj,fieldID,isRepeating){var quantity,quantityFields=elementObj.closest("form").find("[data-frmproduct]");fieldID=fieldID.toString();quantityFields.each(function(){var ids;if(isRepeating&&-1===this.name.indexOf(elementObj.nameMatch))return true;ids=JSON.parse(this.getAttribute("data-frmproduct").trim());if(""===ids)return true;ids="string"===typeof ids?[ids.toString()]:ids;if(ids.indexOf(fieldID)> -1){quantity=this;return false}});return quantity}function getQuantityFields(elementObj,isRepeating){var quantityFields;if(isRepeating)quantityFields=elementObj.closest("form").find('[name^="'+elementObj.nameMatch+'"]'+"[data-frmproduct]");else quantityFields=elementObj.closest("form").find('[data-frmproduct]:not([id*="-"])');return quantityFields}function preparePrice(price,currency){var matches;if(!price)return 0;price=price+"";matches=price.match(/[0-9,.]*\.?,?[0-9]+/g);if(null===matches)return 0; price=matches.length?matches[matches.length-1]:0;if(price){price=maybeUseDecimal(price,currency);price=price.replace(currency.thousand_separator,"").replace(currency.decimal_separator,".")}return price}function maybeUseDecimal(amount,currency){var used_for_decimal,amount_parts;if(currency.thousand_separator=="."){amount_parts=amount.split(".");used_for_decimal=2==amount_parts.length&&2==amount_parts[1].length;if(used_for_decimal)amount=amount.replace(".",currency.decimal_separator)}return amount} function maybeAddTrailingZeroToPrice(price,currency){if("number"!==typeof price)return price;price+="";var pos=price.indexOf(".");if(pos===-1)price=price+".00";else if(price.substring(pos+1).length<2)price+="0";return price.replace(".",currency.decimal_separator)}function addThousands(total,currency){if(currency.thousand_separator)total=total.toString().replace(/\B(?=(\d{3})+(?!\d))/g,currency.thousand_separator);return total}return{init:function(){jQuery(document).on("frmFormComplete",afterFormSubmitted); jQuery(document).on("frmPageChanged",afterPageChanged);jQuery(document).on("frmAfterAddRow frmAfterRemoveRow",calcProductsTotal);jQuery(document).on("click",".frm_trigger",toggleSection);var $blankField=jQuery(".frm_blank_field");if($blankField.length)$blankField.closest(".frm_toggle_container").prev(".frm_trigger").click();jQuery(document).on("click",".frm_remove_link",removeFile);jQuery(document).on("focusin","input[data-frmmask]",function(){jQuery(this).mask(jQuery(this).data("frmmask").toString(), {autoclear:false})});jQuery(document).on("frmFieldChanged",maybeCheckDependent);jQuery(document).on("keyup","input.frm_strength_meter",checkPasswordField);jQuery(document).on("mouseenter click",".frm-star-group input",loadStars);jQuery(document).on("mouseenter",".frm-star-group .star-rating:not(.star-rating-readonly)",hoverStars);jQuery(document).on("mouseleave",".frm-star-group .star-rating:not(.star-rating-readonly)",unhoverStars);jQuery(document).on("click",'.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm_page_back, .frm_page_skip, .frm-show-form .frm_save_draft, .frm_prev_page, .frm_button_submit', setNextPage);jQuery(document).on("change",'.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select',showOtherText);jQuery(document).on("click",".frm_remove_form_row",removeRow);jQuery(document).on("click",".frm_add_form_row",addRow);jQuery(".frm_edit_link_container").on("click","a.frm_inplace_edit",editEntry);jQuery(".frm_edit_link_container").on("click","a.frm_cancel_edit",cancelEdit);jQuery(document).on("click",".frm_ajax_delete",deleteEntry); jQuery(".frm_month_heading, .frm_year_heading").click(function(){var content=jQuery(this).children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s");if(content.hasClass("ui-icon-triangle-1-e")){content.addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-e");jQuery(this).next(".frm_toggle_container").fadeIn("slow")}else{content.addClass("ui-icon-triangle-1-e").removeClass("ui-icon-triangle-1-s");jQuery(this).next(".frm_toggle_container").hide()}});addTopAddRowBtnForRepeater();jQuery(document).on("click", 'input[type="checkbox"][data-frmlimit]',checkCheckboxSelectionLimit);jQuery(document).on("change",'[type="checkbox"][data-frmprice],[type="radio"][data-frmprice],[type="hidden"][data-frmprice],select:has([data-frmprice])',calcProductsTotal);jQuery(document).on("keyup change",'[data-frmproduct],[type="text"][data-frmprice]',calcProductsTotal);maybeDisableCheckboxesWithLimit();setInlineFormWidth();checkConditionalLogic("pageLoad");checkFieldsOnPage();calcProductsTotal()},savingDraft:function(object){return savingDraftEntry(object)}, goingToPreviousPage:function(object){return goingToPrevPage(object)},hideOrShowFields:function(ids,event){if("pageLoad"===event)clearHideFields();var len=ids.length,repeatArgs={repeatingSection:"",repeatRow:""};for(var i=0,l=len;i-1){hidePreviouslyHiddenSubmitButton(hiddenFields[i]);continue}}if(container!==null){container.style.display="none";setHiddenProductContainer(container)}}},submitAllowed:function(object){var formElementId=object.getAttribute("id");if(!isSubmitButtonOnPage(formElementId+" .frm_final_submit")||goingToPrevPage(object)||savingDraftEntry(object))return true;var formKey=getFormKeyFromFormElementID(formElementId); return!isOnPageSubmitButtonHidden(formKey)},checkDependentDynamicFields:function(ids){var len=ids.length,repeatArgs={repeatingSection:"",repeatRow:""};for(var i=0,l=len;i0)for(var i=0,l=opts.length;i